title: Filtering Line based on Word List
body: <p>Hi I have this code that filters all lines for one specific word ('test', I was wondering if anyone could help by explaining how to filter lines with more than just a single word, so if I had a file listing all the filter words and a source file I would be able to display all the source lines that had any of the filter words within it. Thanks! </p>
  
  <pre><code>def cat(openfile):
    with open(openfile) as file:
      return file.read()
  
  def getlinewith(filecontents, containing):
    for item in filecontents.split('\n'):
      if containing in item:
        yield item.strip()
  
  matchedlines = []
  
  for line in getlinewith(cat('C\\testdata_all.txt'), 'test'):
     print(line)
     matchedlines.append(line)
  
  print(matchedlines)
  </code></pre>