There is double quote interpolation in the first print of the original post. I think this is what the author of the exercise expected. The only problem is that it would not edit the first line. That could be fixed with:
$" = '#';
print "#@lines";
The OP's I/O problems hide the fact that he had basically solved the exercise.