$filename = 'whatever';   $fh = @fopen($filename, 'r'); if ( ! $fh ) { throw new Exception("Failed to open ${filename}"); } while ( ( $text = fgets($fh) ) !== false ) { echo $text; }