I have a simple program that writes to a file in a for loop (30k+ iterations). I noticed that the program is taking abnormally long to finish, after which I decided to kill it. The file it is writing to has 29900 lines created withing 30s and the remaining 100 are not written - the program doesn't exit and it takes hours to do so.
Once I killed it, it finished writing the remaining 100 or so lines.
f1 = open('parts.txt', "w") for line in lines: category = line[2] f1.write(category + '\n') print('------- done -------') f1.close() Is there anything obvious that I am missing?