use IO::File; ... my $inp=new IO::File $inputfile,'r' or die("$!"); my $content=join "\n",<$csfile>; undef $inp; # close file my $outp=IO::File->new($outputfile,'w') or die("$!"); $outp->binmode; print $outp $content; $outp->close;