title: Trying to save keywords from a .txt file to an array and use that array to search another doc for the keywords
body: <p>I am trying to save a bunch of keywords in a file called keywordtest.txt containing words such as <code>networkmanager</code>, <code>filemanager</code> and <code>speaker</code> etc. (Each on its own line in the .txt file).</p>
  
  <p>I have got it to save the words into an array but I then want it to use the words stored in that array to search in another document called test and bring up the whole line that the keywords was found in and store that line in another doc called results.txt. </p>
  
  <p>I have managed to get it to search using the words in the array and save them to another file but will only find something if it is not contained in a line: </p>
  
  <p>For example, I search for <code>networkmanager</code> and if it is just <code>networkmanager</code> on a line of its own in the file I am searching in it will find it, but if its like 'I am a networkmanager' for example it wont pick it up. </p>
  
  <pre><code>#!\usr\bin\python
  
  x = []
  
  with open("keywordtest.txt","r") as y:
      for line in y:
          x.append(line)
  print x
  
  theFile = open ("results.txt", "w")
  searchfile = open("test", "r")
  
  for line in searchfile:
      for word in x: 
      if word in line: 
      theFile.write(line)
  
  theFile.close()
  searchfile.close()
  </code></pre>
  
  <p><strong>EDIT:</strong> the code i posted was a version of me when trying something out, i seen online someone using 'word' instead of 'line' in some places and tried it out but it didnt like it, the code below is the code i have got to work but only displays the ekywords i am searching for if they are on their own.</p>
  
  <pre><code>#!\usr\bin\python
  
  x = []
  
  with open("keywordtest.txt","r") as y:
      for line in y:
          x.append(line)
  print x
  
  
  theFile = open ("results.txt", "w")
  searchfile = open("test", "r")
  
  for line in searchfile:
      if line in x: theFile.write(line)
      if line in x: print line
  
  theFile.close()
  searchfile.close()
  </code></pre>