My code looks something like this:
with open(‘myfile.txt’, 'w+') as file:
file.write("some stuff\n”)
file.write(“some more stuff”)
The next line in my code opens a subprocess which reads from myfile.txt. I haven’t had any problems yet, but is this safe? Do I need to do something specific to ensure the file is closed so my subprocess won’t read the old version? Should I use Popen and the wait() command? If so, what is proper syntax? I haven’t seen any working examples.