def putout(ofile, keylist, Rec):
    """
    writes out a magic format record to ofile
    """
    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()
writes out a magic format record to ofile