title: Prepend a single line to file with Ruby
body: <p>I'd like to add a single line to the top a of file with Ruby like this:</p>
  
  <pre><code># initial file contents
  something
  else
  
  # file contents after prepending "hello" on its own line
  hello
  something
  else
  </code></pre>
  
  <p>The following code just replaces the contents of the entire file:</p>
  
  <pre><code>f = File.new('myfile', 'w')
  f.write "test string"
  </code></pre>