my $line = ; my @probs = split ',', $line; $i=0; foreach (@probs) { ++$i; if ( $i % 80 != 0){ print OUT "$_"} else{ print OUT "\n"; } }