open OLD, "new.txt" or die "Could not open new.txt: $!"; my $i = 0; while () { chomp; $_ .= $table[ $i++ ]; print NEW "$_\n"; } close OLD; close NEW;