title: How can I prepend a line to the beginning of a file?
body: <p>I'm trying to add a new line to the beginning of a text file. I start by opening the file with <code>append</code> but that only allows me to use <code>write_all</code> to write to the end of the file, at least that's the result I'm getting. If I read the documentation correctly, this is by design.</p>
  
  <p>I've tried to play with <code>seek</code>, but that didn't solve it.</p>
  
  <p>This is what I have currently:</p>
  
  <pre><code>let mut file = OpenOptions::new().append(true).open(&amp;file_path).unwrap();
  file.seek(SeekFrom::Start(0));
  file.write_all(b"Cool days\n");
  </code></pre>
  
  <p>If I open the file with <code>write</code>, I end up overriding data instead of adding. What would be the appropriate way to go about accomplishing this with Rust?</p>