code: def putout(ofile, keylist, Rec):
      
      pmag_out = open(ofile, 'a')
      outstring = ""
      for key in keylist:
          try:
              outstring = outstring + '\t' + str(Rec[key]).strip()
          except:
              print(key, Rec[key])
              # raw_input()
      outstring = outstring + '\n'
      pmag_out.write(outstring[1:])
      pmag_out.close()
docs: writes out a magic format record to ofile