try this for creating a file. once the file is created use unlink to remove it if needed?
<?php
$file='';
$file=$_GET['msg'] ;
$msg = isset($_GET['msg']) ? htmlspecialchars($_GET['msg']) : ".";
$lines = "<p><font color=grey>$nick says:</font><br><font color=green>$msg</font>";
if (isset($_GET['msg'])){
if (file_exists($file)) {
$f=fopen($file,"a+");
}
else {
$f = fopen($file,"w+");
}
fwrite($f,$lines."\r\n");
fclose($f);
echo $lines;
$flag = file($file);
$content = "";
foreach ($flag as $value) {
$content .= $value;
}
echo "<br>";
echo $content;
you can also ad an extention to the file like txt etc. Also you can use post variable to creat the file using the above Code. Works for me fine. If need any help let me know?