in reply to file test operations

stat doesn't require an open file handle. The following will do:
my @file_info = stat($output_file) or die "$output_file: stat failed: $!\n";