Like i said, if you show us some more code - at least a self-contained example that can be run - that demonstrates the problem, I'm sure you'll get the answer very quickly.
Cheers,
Darren :)
Comment on Re^3: Find partially matching line in file - print that line to another file