<html>
<head>
<title> Append to wherever ou want in the file</title>
</head>
<body>
To add a line, simply append "?input=&lt;text&gt;" at the end of the URL.
<?php
$filename 
"file.txt";
$fd fopen ($filename"r");
$contents fread ($fdfilesize ($filename));
fclose ($fd);

$input $_REQUEST["input"];
if(
$input){
  
$fd fopen ($filename"w");
  
$contents preg_replace("/<!-- NEW NEWSITEM -->/""<!-- NEW NEWSITEM -->\r\n".stripslashes($input), $contents);
  
fwrite($fd,$contents);
  
fclose ($fd);
}

$output nl2br(htmlspecialchars($contents));
echo 
"<h3>The file contains:</h3>".$output;
?>
</body>
</head>