title: writing without closing in python
body: <p>i want to write to text file without closing because i don't know what i'll stop close,i'll explain the hole issue </p>
  
  <p>i've create text called <code>resume.txt</code> , so after each specific processes in my project  it will overwrite in <code>resume.txt</code> so every time my project start it will check that file to know the last processes so my issue after each writing i have to close to apply it and i don't really think this is good i think there is better solution </p>
  
  <p>this code will not work</p>
  
  <pre><code>wr = open('resume.txt','w')
  login(usr,pas)
  wr.write('login')
  post(msg,con)
  wr.write('post')
  ..so on 
  </code></pre>
  
  <p>the issue is how to write without closing , i can't write the <code>wr.close</code> at the end because it might be terminated by the user or connection time out .. etc </p>