Does removing the $ at the end of your regexp fix the problem? I'm assuming that given the content of the file you are parsing you are running this script in windows? Is there a
? if not then you definately have some characters hanging around after the ] that you can't see...Droping the anchor all together will give you the most flexibility as long as the text