# Print final output for each subject. for x in range(len(subjectID)): try: finalString = subId(subjectID[x]) + '\t' + ep1(epLines[x]) + '\t' + ep2(epLines[x]) + '\t' + dep1(depLines[x]) + '\t' + dep2(depLines[x]) except (IndexError): try: finalString = subId(subjectID[x]) + '\t' + ep_dep1(ep_depLines[x]) + '\t' + ep_dep2(ep_depLines[x]) except (IndexError): try: finalString = subId(subjectID[x]) + '\t' + mean(meanLines[x]) except (IndexError): pass finally: # Write output file. fOut = open(outFile, 'a') fOut.write(finalString + "\n") fOut.close()