my $csv = Text::CSV->new ({ binary => 1, eol => "\n" }); open(my $out,">>",$outfile); open (CSV, "<", $file) or die $!; while() { my @array=split /\s+/; $csv->print($out,\@array); }