Hey folks. I've been beating my head against this one.
I'm trying to simply write to a file, then immediately read from the file with another function.
My code does write okay, but the immediately following read doesn't seem to notice.

Any help would be astounding. Thanks.
Code:
<?php
function appendToFile($text_filename,$new_content)
{
$this_file = fopen($text_filename,"r");
if (!$this_file)
{print("Error: Can not open: $text_filename for read.");}
else
{
$new_content=fread($this_file, filesize($text_filename)).$new_content;
fclose($this_file);
}
$this_file = fopen($text_filename,"w");
if (!$this_file)
{print("Error: Can not open: $text_filename for write.");}
else
{
fwrite($this_file,trim($new_content));
fclose($this_file);
}
print("<BR><BR>ITEM APPENDED<BR><BR>");
}
function showFile($text_filename)
{
$this_file = fopen($text_filename,"r");
if (!$this_file)
{print("Error: Can not open: $text_filename for read.");}
else
{
$new_content="";
print(fread($this_file, filesize($text_filename)));
fclose($this_file);
}
return null;
}
appendToFile("test.txt","ITEM!<BR>\n");
showFile("test.txt");
?>