foreach my $i (0..$#chunk) { print TO_WRITE $chunk[$i] unless $i == $number; }