Using the code shown below I am recording time vs. voltage readings to a logfile. I notice that if I "open" the logfile while the program is running it does not show any new data. It only shows data that was already there in logfile.txt from the previous running of the program. In order for the new data to show up in logfile.txt, I have to stop the running program(cntl-C), then reopen logfile.txt. The new data must be recorded somewhere. Why doesn't live data show up in the logfile?
import sys, time, signal
with open('logfile.txt', 'a') as f:
while True:
volts = adc.read(256, 8)
print >> f, time(), volts