in reply to How to test for open file handles?

A tip: I always code the close at the same time as the open to make sure I close files as soon as I'm done with them. This not only reduces the chance of the "too many open files" type of errors it also reduces the time the file is locked and reduces the chance of file corruption if your program crashes with open files.