title: fputcsv in PHP will not write to file
body: <p>I've have searched and searched and done extensive debugging and for the life of me cannot figure out why fputcsv is not working for me.  </p>
  
  <p>I can sucessfully open the .csv file and write to it.  </p>
  
  <p>My debugging proves that the array is properly loaded and that the foreach loop is working correctly. However, the fputcsv function fails to write anything at all. I have removed all strings that I though may cause a problem such as URLs etc, but it still will not write.  </p>
  
  <p>I am the only person with access to this environment, so I know it is not a file lock conflict. I can create the file and write to it, so I know it is not a permissions issue. And, I get debug output from the foreach loop, so I know it is not an issue with the array or the loop.</p>
  
  <p>I'll provide my code and debug log below...</p>
  
  <pre><code>$posts_meta = array(
      'twitter_title'       =&gt; $this_title,
      'twitter_brandtag'    =&gt; $this_brandtag,
      'twitter_hashtags'    =&gt; $this_hashtags,
      'twitter_iterations'  =&gt; $this_iteration,
      'twitter_timing'      =&gt; $this_timing,
      'twitter_time'        =&gt; $this_time,
      'twitter_id'          =&gt; $post_id,
   );
  
  // Debuging
  file_put_contents("/blog/debug.txt", "About to write CSV file.\n", FILE_APPEND);
  file_put_contents("/blog/debug.txt", print_r($posts_meta, true)."\n", FILE_APPEND);
  
  $myfile = fopen('/blog/pdm_twitter_ouptut.csv', 'a+');
  
  // More debugin
  file_put_contents("/blog/debug.txt", "myfile handle = ".$myfile."\n", FILE_APPEND);
  fwrite($myfile, "This file is open and working.\r\n");
  
  foreach ($posts_meta as $fields){
      $fresponse = fputcsv($myfile, $fields);
  
      // A little more debugging...
      file_put_contents("/blog/debug.txt", $fields."\n", FILE_APPEND);
  }
  
  fclose($myfile);
  
  // And more debugging
  file_put_contents("/blog/debug.txt", "fputcsv response = ".$fresponse."\n", FILE_APPEND);
  file_put_contents("/blog/debug.txt", "Just closed CSV file.", FILE_APPEND);
  </code></pre>
  
  <p>And here is the resulting Debug log...</p>
  
  <pre><code>About to write CSV file.
  Array
  (
      [twitter_title] =&gt; World Stocks Up As US Jobs, China Exports Improve
      [twitter_brandtag] =&gt; - FP test 9
      [twitter_hashtags] =&gt; #Economy #Markets #Business #Investing #Stocks
      [twitter_iterations] =&gt; 12
      [twitter_timing] =&gt; 240
      [twitter_time] =&gt; 2013-03-08 07:55:24
      [twitter_id] =&gt; 11051
  )
  
  myfile handle = Resource id #548
  
  // Print-out of $fields here...
  World Stocks Up As US Jobs, China Exports Improve
  - FP test 9
  #Economy #Markets #Business #Investing #Stocks
  12
  240
  2013-03-08 07:55:24
  11051
  
  fputcsv response =      // Hm!? I wonder why no response code?
  Just closed CSV file.
  </code></pre>
  
  <p>All that appears in the .csv file is (as you can see in the debug code above) "This file is open and working."</p>
  
  <p>Any thoughts anyone may have would be greatly appreciated!</p>
  
  <p>Thanks so much!!!</p>
  
  <p>Trip</p>