title: Create text file Python not working - Raspberry Pi
body: <p>I have tried a simple write .txt file in a python script using Raspberry Pi B+ but is not working. It does not show any error but I can see the file.
  The code is:</p>
  
  <pre><code>file = open('log.txt','r')
  file.write('hi'+'\n')
  file.close()
  </code></pre>
  
  <p>I have tried with <strong>'w+'</strong> , <strong>'a'</strong> , <strong>'w'</strong>; and reboot.</p>
  
  <pre><code>python Desktop/BQ/log.py
  </code></pre>
  
  <p>And when opening the file it shows the error that does not exist in the directory:</p>
  
  <pre><code>cat Desktop/BQ/log.txt
  </code></pre>
  
  <p>Thanks for any help.</p>