title: Using "with open() as file" method, how to write more than once?
body: <p>Usually to write a file, I would do the following:</p>
  
  <pre><code>the_file = open("somefile.txt","wb")
  the_file.write("telperion")
  </code></pre>
  
  <p>but for some reason, iPython (Jupyter) is NOT writing the files.  It's pretty weird, but the only way I could get it to work is if I write it this way:</p>
  
  <pre><code>with open('somefile.txt', "wb") as the_file:
      the_file.write("durin's day\n")
  
  with open('somefile.txt', "wb") as the_file:
      the_file.write("legolas\n")
  </code></pre>
  
  <p>But obviously it's going to recreate the file object and rewrite it.  </p>
  
  <p>Why does the code in the first block not work? How could I make the second block work?</p>