in reply to if/while/else problem

You probably want something like this:

open FILE2, '>', 'file2' or die "Cannot open 'file2' $!"; open MYINPUTFILE, '<', 'file' or die "Cannot open 'file' $!"; while ( my $line = <MYINPUTFILE> ) { chomp $line; print FILE2 "$line\n", "you need to do this\n"; } unless ( $. ) { print FILE2 "There is nothing to do\n"; }