in reply to Error Message in Closing File
The OP is using lexical filehandles and the three argument form of open which is perfectly correct from perl 5.6.x onwards.
Cheers,
JohnGG