title: The best and speedy way to write to a file
body: <p>I want to know what the best way is to write to a file, which consumes less memory and less CPU, and is high speed.</p>
  
  <p>I have the below code:</p>
  
  <pre><code>file = "some_path/some_name.txt"
  File.open(file, 'wb') do |f|
    f.syswrite(params[:file_content])
  end
  </code></pre>
  
  <p>I want to know which of <code>f.write,f.syswrite</code> and <code>f.puts</code> is the best method to write to a file. Also if there is something better than this, then please let me know.</p>