in reply to Getting correct filename

Also, it sounds like you don't know "otherinfo" until you've proccessed the file. So, you should put all output in an array and write it to a file at the end, when you know the name, or write to a temporary file and rename it at the end. Mark.