Help for this page
use strict; use warnings; ... print DEBUG_FILE $output if $debug_flag; # etc...
# warning, not tested ... # and then always do: print $out_fh $output; # it will go to the right place.