title: ob_get_contents is empty following fputcsv calls
body: <p>I have copied a function which you pass an array and a temporary download file. The array has lots of things in it (it comes from a simple select * from table query) and the file is in an empty folder with 777 permissions.</p>
  
  <pre><code>function array_to_csv($array, $download) {
      ob_start();
      $f = fopen($download, 'wb') or show_error("Can't open php://output");
      $n = 0;        
      foreach ($array as $line)
      {
          $n++;
          if (!fputcsv($f, $line))
          {
              show_error("Can't write line $n: $line");
          }
      }
      fclose($f) or show_error("Can't close php://output");
      $str = ob_get_contents();
      ob_end_clean();
  
      echo $str;
  }
  </code></pre>
  
  <p>It runs without errors and calls fputcsv several hundred times for every row in my array.</p>
  
  <p>However when it gets to the end and gets the output buffer str is empty. Is this a file problem or a buffer problem? When I look in the folder there is nothing there. Should there be?</p>