Here is a read function that works for me. Odds are some of it is not needed. I am just learning myself and one thing I learned a long time ago about computers whether it is a program, or a programming language, odds are good there are more than one way to accomlish the same thing.
Silk
IO ($filename=$filename, "r");
function IO ($filename, $io) {
$channel=curl_init($location);
$file=fopen($filename, $io) or die($php_errormsg);
curl_setopt($channel, CURLOPT_FILE, $file);
curl_setopt($channel, CURLOPT_HEADER, 0);
curl_setopt($channel, CURLOPT_NOBODY, 0);
curl_exec($channel);
$data=strip_tags(fread($file, filesize($filename)));
curl_close($channel);
fclose($file) or die($php_errormsg);
print "<div><hr><p class=\"view\">View of created document...</p><h1 class=\"data\">$data</h1></div>";
}