title: Php function loop with file handle
body: <p>This function is causing big trouble on my server because is in loop:</p>
  
  <pre><code>function loadFiles()
  {
  $email = $_POST["emailp"];
  $file_handle = fopen("/tmpphp/dmbigmail.file", "r");
  while (!feof($file_handle)) {
  $line = fgets($file_handle);
  if(stristr($line,$email)){
      $show = trim(str_replace($email,' ',$line));
      //echo $show;
      $parsedata = substr($show,0,11);
      $parselink = substr($show,10);
      $total = $parsedata.'&lt;a href=' . $parselink. "&gt;$parselink&lt;/a&gt;&lt;br&gt;";
      echo $total;
      }
       }
       fclose($file_handle);
   }
  </code></pre>
  
  <p>In my log I can see this:
  "PHP Warning:  fgets() expects parameter 1 to be resource, boolean given in /path/file.php on line 42"</p>
  
  <p>The line interested is: </p>
  
  <pre><code>$line = fgets($file_handle);
  </code></pre>
  
  <p>The function is ok, but I dont know why give me this strange error.</p>