Assuming the subs do whats thier names suggest, i believe the problem is that you run the finalScreenOut sub within the loop. I would think that from it's name, it is possibly calls
. After the close you would get messages about printing to a closed filehandle if you are running under
. Not sure, would need to see the code, but sounds like it could be right.