open(FILE, $listfile); while(my $user = ) { $user =~ s/(\r|\n)//; # windows compatibility $userout .="$user,"; $lcount++; if ($lcount == 20) { print PIPE "$userout"; $lcount=0; } next if !$user; }