It is your ereg_replace()
From php.net:
string ereg_replace ( string pattern, string replacement, string string)
You do:
$text = ereg_replace("<","<",$text);
$text = ereg_replace(">",">",$text);
on the text from the file, and replaces all tags with their text-only-equivalent.
Which format is the code in the file? Try to comment the sentences above out, and see if the code executes.
knutm