use warnings; use strict; open (outputFile, ">", "TestNew.txt"); my @infoArray = (1, 2, 3, 4, 5, '\n', 6, 7, 8, 9, 10, '\n'); my $x = 0; my $test = "\n"; my @finalArray = join ("\t", @infoArray); foreach (@finalArray) { if ($_ eq $test) { splice (@finalArray, $x + 1, 1); } else { $x = $x + 1; } } print outputFile @finalArray;