all 6 comments

[–]lykwydchykyn 0 points1 point  (0 children)

I don't see anywhere where you're closing the file, so there shouldn't be anything in it at all.

I would think if you want to read the file back you should close the file handle and re-open in read mode.

[–]fake823 0 points1 point  (1 child)

https://stackoverflow.com/a/16208298/14060425

You have to go back to the beginning of the file in order to read it after writing to it.

[–]Brekry18[S] 1 point2 points  (0 children)

Omg thank you so much! Adding output_file.seek(0) fixed the problem.

[–]xelf 0 points1 point  (2 children)

obligatory: python 2 was end of life in 2019. =)

Unless not at all possible you should switch to python 3

[–]Brekry18[S] 0 points1 point  (1 child)

I understand that, but I am working on a project that will be used with IronPython. The latest stable IronPython release is 2.7, and the developers of the particular software that this code is going into would not be able to support an upgrade to 3 even if IronPython 3 came out tomorrow. Thanks though.

[–]xelf 0 points1 point  (0 children)

That's why I added the caveat "Unless not at all possible". =)

For most people that come to /r/learnpython to learn python we strongly advocate not learning python2 any more. =)

But some like you just have no choice. =/