Keith,
There are a couple of problems with your script.
1. You need to 'escape' the backslash in strings. So the code for creating your file should look like this:
var tagsFile = new File ("C:\\extend\tag_list.txt")
2. You cannot write the pgf to a text file as the pgf is an object that contains a whole lot of properties. I am not sure which property you want to write to the text file, but if you want to write the paragraph format tag, you should use:
tagsFile.writeln (pgf.NextPgfInFlow.Name);
Good luck
Jang