title: Censor Words from a File Using a CensorFile - Python
body: <p>I'm trying to create a 'censor' program which reads in a 'censorlist' with words to censor out of a 'censorfile'. I feel like I'm close, but when I run the program it's only censoring one line. Any help would be greatly appreciated!</p>
  
  <pre><code>#!/usr/bin/python
  
  import sys, os
  
  censorlist = raw_input("File with words to censor? ")
  if os.path.isfile(censorlist):
    print "The file", censorlist, "exists!"
  else:
    print "The file", censorlist, "doesn't exist!"
    sys.exit()
    print ""
  
  filterword = {}
  for currentline in censorlist:
    line = currentline.strip()
    filterword.append(line)
  
  censorfile = raw_input("File to censor using provided list? ")
  script = []
  for currentline in censorfile:
    line = currentline.strip()
    script.append(line)
  
  for lines in script:
    results = []
    words = lines.split()
    for word in words:
      if word in filter:
        results.append("****")
      else:
        results.append(word)
  
  resultfile = open(censorfile, 'w')
  for items in results:
      resultfile.write(items)
  </code></pre>