title: Append a text to file?
body: <ol>
  <li>How to check that the file exists?</li>
  <li>How to append a text to the file?</li>
  </ol>
  
  <p>I know how to create the file, but in this case, it overwrites all data:</p>
  
  <pre><code>import io
  
  with open('text.txt', 'w', encoding='utf-8') as file:
      file.write('text!')
  </code></pre>
  
  <p>In <code>*nix</code> I can do something like: </p>
  
  <pre><code>#!/bin/sh
  
  if [ -f text.txt ]
      #If the file exists - append text
      then echo 'text' &gt;&gt; text.txt; 
  
      #If the file doesn't exist - create it
      else echo 'text' &gt; text.txt;  
  fi;
  </code></pre>