title: Move/rewrite a txt file that matches a string in a folder with multiple txt files
body: <p>I'm trying to use python to search for a string in a folder which contains multiple .txt files. <br>
  My objective is to find those files containing the string and move/or re-write them in another folder. 
  what I have tried is:</p>
  
  <pre><code>import os
  
  for filename in os.listdir('./*.txt'):   
      if os.path.isfile(filename):    
          with open(filename) as f:   
              for line in f:  
              if 'string/term to be searched' in line:
                  f.write
                  break
  </code></pre>
  
  <p>probably there is something wrong with this but, of course, cannot figure it out.</p>