title: MSI log file reader is not writing the results to the text file
body: <p>I have created a MSI log file reader that searches for specific log file names that a some installers leave behind during installation. It prints results separately in the shell but is not writing them to the created "MSI_Return.txt" file.</p>
  
  <pre><code>#Import Python Modules
  import os
  import fnmatch
  
  #Create a find function to search the directories for the file name
  def find(pattern, path):
      result = []
      for root, dirs, files in os.walk(path):
          for name in files:
              if fnmatch.fnmatch(name, pattern):
                  result.append(os.path.join(root, name))
      return result
  
  #Get the full list of LOG files from specified folder
  infile = os.path.expanduser('~\\AppData\\Local\\Temp')
  listoffiles = find("MSI*.LOG", infile)
  
  
  #Process each file name in the file name array
  key_phrases = ["Error",
                "Failed",
                "Exception", "Return Value 3"]
  important = []
  for eachfile in listoffiles:
      #Open the file
      with open(eachfile) as i:
          i = i.readlines()
      #Look through the lines for phrases
      #If a phrase is found, append it to an array
      for line in i:
          for phrase in key_phrases:
              if phrase in line:
                  important.append(line)
                  break
  
  #Return output
  MSI_Return = open('MSI_Return.txt','w')
  MSI_Return.write('List of MSI files = ' + str(listoffiles))
  MSI_Return.write('\n')
  MSI_Return.write('Return of key lines from MSI files = ' + str(important))
  MSI_Return.close
  </code></pre>
  
  <p>Any thoughts or input would be appreciated.</p>