title: Read a file continuously and sending the output to another file
body: <p>I have a file 'out.txt' that is updated continuously. I need to send the contents of this file periodically to another file 'received.txt' every N minutes.  I do not want the previous lines to be sent. So the scripts needs to send the new data and update 'received.txt' with the new lines of txt, but not repeat lines.</p>
  
  <p>I'm having a hard time putting this script together. I'm guessing I need some sort of loop to do this continuously. Here is what I have so far. (not in order)</p>
  
  <p>EDIT: I am using Debian(Raspbian) on a Raspberry Pi</p>
  
  <pre><code>import sys
  
  num_lines = sum(1 for line in open('out.txt')) # read the last line of the updated file
  
  sys.stdout = open('received.txt', 'w')  #write to the received.txt file
  print 'test'
  
  f = open('out.txt', 'r') #read the data from the last line
  f.readline(num_lines)
  for line in f:
      print line
  </code></pre>
  
  <p>Any advice would be extremely helpful.
  Thank you</p>