Your statement of the problem is a bit vague. It looks like
you're trying to copy an input file to an output file. Is
(part of) the problem that the copy stops before all the data has
been written? Are you on a windows system, reading files
with binary (non-text) content? If so, do you know about
"binmode()"?
In addition to checking the status returned
by the open statement, you might want to print out the final
value of $bytes_read for a given input file -- if it's less
than the actual size of the file, try "binmode($file_handle)".