try storing the whole file into a string in the session,
then the place in the string you are showing in the session,
then print out just the portion you want.
also i found out that phoenic (my browser of choice) does not handle the header('Refresh') kindly, it tends to collect them and duplicate the refreshes, instead of overwriting one refresh. so i dropped down to using acutal <header> tags
<?php
#session_unset();
#session_destroy();
#die;
/// if this is out first time through
/// store all important info in the session, send off initial refresh header
if ( !isset($_SESSION['file_name']) ) {
$_SESSION['file_name'] = 'hello.txt';
$_SESSION['file_size'] = filesize($_SESSION['file_name']);
$_SESSION['file_text'] = implode('',file($_SESSION['file_name']));
$_SESSION['file_offset'] = 0;
}
/// unncessary but convenient wrist savers
$file_offset =& $_SESSION['file_offset'];
$file_text =& $_SESSION['file_text'];
$file_size =& $_SESSION['file_size'];
$file_name =& $_SESSION['file_name'];
if ( $file_size > $file_offset ) {
$file_offset = min(++$file_offset,$file_size);
$header = "<meta http-equiv='refresh' content='1;URL={$PHP_SELF}'>";
} else {
$file_offset = 0;
$header = "<meta http-equiv='refresh' content=''>";
}
/// format the slice of the file we want all pretty for html
$file_so_far = nl2br(htmlentities(substr($file_text,0,$file_offset)));
$displayed_portion = substr($file_text,0,$file_offset);
$undisplayed_portion = substr($file_text,$file_offset);
print <<<END
<html>
<head>{$header}</head>
<body>
<fieldset style="width:300px">
<legend>Script Info</legend>
file name = {$file_name} <br/>
file size = {$file_size}<br/>
next offset = {$file_offset}<br/>
<fieldset style="width:300px">
<legend>File Content</legend>
<pre><span style="background-color: #DDDDDD;">{$displayed_portion}</span>{$undisplayed_portion}</pre>
</fieldset>
</fieldset>
<br />
<br />
<font face='Com' size='7'>{$file_so_far}</font>
</body>
</html>
END;
?>