title: Errno=9 bad file descriptor in php
body: <p>Im trying to write a file in php with the following code</p>
  <pre><code>    $filename = &quot;uploads/stories/&quot;.$row['s_source'];
      $handle = fopen($filename, &quot;r&quot;);
      if (filesize($filename) == 0) {
        $txt = &quot;{====views====}{====likes====}{====chapters====}{====comments====}&quot;;
        fwrite($handle, $txt);
      }
      $content = fread($handle, filesize($filename));
      fclose($handle);
  </code></pre>
  <p>And I get:</p>
  <blockquote>
  <p>Notice: fwrite(): write of 66 bytes failed with errno=9 Bad file descriptor in E:\xampp\htdocs\host\host\storyedit.php on line 20</p>
  <p>Warning: fread(): Length parameter must be greater than 0 in E:\xampp\htdocs\host\host\storyedit.php on line 22</p>
  <p>Notice: Undefined offset: 1 in E:\xampp\htdocs\host\host\storyedit.php on line 27</p>
  </blockquote>
  <p>But there is no error (I think) in the code. Could someone help me?</p>
  <p>I've tried:</p>
  <ol>
  <li>Deleting opcache.enable_cli=1 in php.ini</li>
  <li>Deleting cache</li>
  </ol>
  <p>none worked.</p>