Unfortunately, there is not much flexibility in how the script will be receiving its input. It must accept a stream that is piped to its standard input, without knowing the identity of the files that make up that stream. So the file handle that it has is the file handle for STDIO, which it would not want to close before passing.
The only way that the script can tell one file from the next in the incoming stream is by matching the identifying information that comes in the first line of each file. Then it needs to pass the STDIO filehandle to a subroutine to parse the file.