FIELDS = ["MS", "StartYear", "YourStartAge", "HerStartAge", "Exempt",
"BFedItmDed", "FedItmDedYrs", "State", "LivExp", "Inflation", "Inf1",
"Inf2", "Inf3", "Inf4", "Inf5", "Inf6", "Inf7", "Inf8", "Inf9", "Inf10",
"TESTPcnt", "TESTYr", "TFISTPcnt", "TFISTYr", "TFESTPcnt", "TFESTYr",
"TFFISTPcnt", "TFFISTYr", "TDESTPcnt", "TDESTYr", "TDFISTPcnt", "TDFISTYr",
"BTE", "BTFI", "BTC", "TERtn", "TFIRtn", "TCRtn", "BTFE", "BTFFI", "BTFC",
"TFERtn", "TFFIRtn", "TFCRtn", "BTDE", "BTDFI", "BTDC", "TDERtn", "TDFIRtn",
"TDCRtn", "YourJob", "SpJob", "YourRetInc", "SpRetInc", "YourSSInc62",
"YourSSIncFRA", "YourSSInc70", "SpSSInc62", "SpSSIncFRA", "SpSSInc70",
"YourRetAge", "SpRetAge", "YouBgnRetIncAge", "SpBgnRetIncAge",
"YouSSStartAge", "SpSSStartAge", "IraStartAge", "IraEndAge", "IraRequest"]
with open("in_file.txt") as in_file, open("out_file.txt" 'w') as out_file:
for line in in_file:
data = {key: val for (key, value) in zip(FIELDS, line.strip().split()}
# do something with data presumably converting some of them to
# the needed data types for calculation.
out_file.write(" ".join(data[key] for key in FIELDS) + "\n")