in reply to checking a file handle to see if it is open
I guess what you asked for is something like:
close FH unless eof FH;
Enjoy, Mickey