I am able to read GPS data through gpsd and gps pipe. But when I try to read GPS data in python code and write to a file in the same code. The file remains empty
import serial import time ser = serial.Serial('/dev/ttyS0') f=open("myFile.txt","w+") while 1: x=ser.readline() print (x) f.write('writing to a file \n')
GPS data is displayed correctly and myFile.txt is created. But when I open it is blank. Can anyone help me on this?
Note: I have tried this while using reading other devices through the USB-port and it works just fine