Use file_put_contents() instead like this and there's no need to create the tracking.txt: <?php $errcode = "errorpagecode"; $ip = $_SERVER['REMOTE_ADDR']; $page = $_SERVER['REQUEST_URI']; $dayassoc = getdate(); $output = $ip."\t".$page."\t".$dayassoc['mon']."/".$dayassoc['mday']."/".$dayassoc['year']."\t".$dayassoc['hours'].":".$dayassoc['minutes']."\t".$errcode."\r\n"; file_put_contents("tracking.txt", $output, FILE_APPEND); ?>