in reply to File manipulation only works when I split it into two files.

Your script didn't work because exec doesn't return anymore after it executes the rm and mv commands. Note that the error message gives a strong hint when it tells you that you probably wanted to call system() instead of exec.

This is something to remember, especially if you don't have the motivation to learn beforehand: Always inspect error messages, they are here to tell you something and often (as in this case) they give you a hint what you have to look up to understand the problem

Update: You also might want to add http:// only when it is necessary:

$line= 'http://' . $line if (not $line=~/^http:/); print $new $line;