title: Continuously Parse file in Python
body: <p>I'm writing a script that parses a file with HTTP traffic lines, and takes out the domains and currently just prints them to the screen. I'm using httpry to continuously write the traffic to a file. Here is the script I'm using to strip out the domain names</p>
  
  <pre><code>#!/usr/bin/python
  
  import re
  
  input = open("results.txt","r")
  
  for line in input:
      domain = line.split()[6]
      if domain != "-":
          print domain
  </code></pre>
  
  <p>While this script works great, I'd like a way to continuously run this script so that as new traffic gets added to the input file, the script is able to strip it out. I can't just run awk on the output of httpry, as I'm eventually going to be entering these domains into a Mongo database, and I'll need the script to do that as well. If anyone could give me some ideas how to constantly run this python script on the output, but not reprint previous entries, it would be much appreciated. Thanks.</p>