title: loop input to glob and write results to .txt
body: <p>I'm attempting to us a list of strings as input to glob and write the results respective to each input string as a separate .txt file but have so far been unsuccessful, I've searched for other problems but none seem to looping within a loop as I imagine I will need to? Thanks</p>
  
  <pre><code>import os
  import glob
  
  # Generate a list of modis data julian days
  julian_days = []
  
  for day in range(1,365, 8):
      julian_days.append(str('MOD09A1.A2015' + (str('{:03d}'.format(day))) +'*.hdf'))
  
  for day in julian_days:
      results = glob.glob(str(day))
      myfile = open(((str(day[:-5])) + '.txt'), "w")
      for line in results:
          myfile.write(results, lineterminator='\n')
  </code></pre>