title: Copy CSV content to another CSV
body: <p>I'm trying to copy the content of a CSV file to another one.</p>
  
  <p>First attempt:</p>
  
  <pre><code>FileUtils.cp(source_file, target_file)
  </code></pre>
  
  <p>Second attempt:</p>
  
  <pre><code>CSV.open(target_file, "w") {|file| file.truncate(0) }
  CSV.open(target_file, "a+") do |csv|
   CSV.foreach(source_file, :headers =&gt; true) do |row|
    csv &lt;&lt; row
   end
  end
  </code></pre>
  
  <p>Third attempt:</p>
  
  <pre><code>CSV.open(target_file, "w") {|file| file.truncate(0) }
  File.open(source_file, "rb") do |input|
   File.open(target_file, "wb") do |output|
    while buff = input.read(4096)
     output.write(buff)
    end
   end
  end
  </code></pre>
  
  <p>Nothing is happening. What am I doing wrong?</p>
  
  <p>When I run from Terminal <code>cp source_file target_file</code>, the target file is correctly created/copied. But in my app it is just creating the <code>target_file</code>, without any content.</p>