in reply to Filehandle Error

The code you put up is hard to follow. A lot of variables are undeclared and there are lines missing. At the very least you should have indicated which line is line 44, where the error occurred.

The problem is that you're closing STDOUT. If you do that the system file descriptor (1) for STDOUT becomes available. The next open() (in your line 44) picks up that file descriptor and tries to open a file for reading on it. That results in the warning (not error) you have seen.

Anno