title: Python - Writing and continuously updating a file
body: <p>I have the following code to write data into a file continuously:</p>
  
  <pre><code>matrix=open("matrix.txt","r+")
  i=0
  while i&lt;100:
      for row in range(10):
          matrix.write('\n')
          for column in range(10):
              matrix.truncate()
              matrix.write(str(i))
              time.sleep(0.5)
              i+=1
  matrix.close()
  </code></pre>
  
  <p>It is working, but in order for me to view the updated data, I have to reload the file every time by clicking on the reload button when my OS (linux) tells me the file has changed, is there a way for it to update and continuously show the updated file with each iteration without me having to click the button?</p>