in reply to if/while/else problem

Within your while loop you have a FILE error.
while(<MYINPUTFILE>) { my($line) = $_; chomp($line); print FILE2 "$line\n"; print FILE2 "you need to do this\n"; print FILE " \n"; <------ *HERE* } else {
Should probably be FILE2. I am making an assumption though because we don't have all of the code and you could possibly have FILE defined further up.