If you print the contents of a file into a textarea, you should use htmlspecialchars() or htmlentities().
When the used press the Send button, you'll get the content of the textarea with $_POST["the name of the textarea"]. Example:
$usertext = $_POST["contents"];
But you should use stripslashes to convert all \" to ", \' to ', etc...
$usertext = stripslashes($_POST["contents"]);
Then, to write it to a file :
$fp = fopen("/path/filename.extension", "w+");
fputs($fp, $usertext);
fclose($fp);
And that's it !