title: How can I check if a file is empty or not? and empty it before writing if not?
body: <pre><code>myfile = open('out.txt', 'a')  
  myfile.write(caption)
  </code></pre>
  
  <p>I write something like this whenever my script is run. But after the first run, it keeps on adding same data to the file. How can I check if it's empty or not and tell it to write only if it's empty? </p>