in reply to removing \n with for each
chomp @lines; [download]
If you want to delete the newline only from the last line, use
chomp $lines[-1]; [download]