in reply to file reading issues

You will get all manner of horrible things happen to your current code if the page that you're editing happens to contain the string "</textarea>" in it anywhere.

You should escape the HTML that you are printing inside the text box to get around this. At a minimum, replacing all instances of "<" with "&lt;" should do the trick. There are modules such as HTML::Sanitizer which try to do this in a more sophisticated way.