title: Saving output of a query onto a text file in Ruby
body: <p>I'm trying to query a table, fetch all records, and save the result as a CSV file. 
  This is what I've done so far:</p>
  
  <pre><code>require 'OCI8'
  conn = OCI8.new('scott','tiger','020')
  file = File.open('output.csv','w')  do |f|
  conn.exec('select * from emp') do |e|
     f.write log.join(',')
   end
  end
  </code></pre>
  
  <p>.. And while it does generate a CSV file, the problem is that all records get saved onto a single line. How can I put the data such that each record goes onto a new line ?</p>