use warnings; use strict; my $infile="clients.txt"; open my $in, "<", $infile or die $!; open my $out, ">" , "clients.csv" or die $!; my $clients = print join ("\t\t" => qw(Name Phone E-mail)),$/; while (<$in>) { chomp; print $_, "\t"; print $/ if $. % 3 == 0; # note here }