I wrote a program that periodically(every minute) receives updated data from server. Once the data is received it overwrites to the corresponding line of the file. ( code below )
Code below runs fine for first few iterations but throws IOException after.