in reply to Changing the output filehandle while iterating input files.
There is. Don't use <>, use open/close and you won't have to check.