open (FILE, "> redo-output.txt") or die "Error: $!"; foreach (@lines) { print FILE "$_\n"; } close(FILE);