Thanks.
I've ended up reading everything from the file into an array, adding the changes for the file into the array, and then writing everything from the array into the file. I make sure that when I write the first line, I'm overwriting the content of the file - and then appending the content in subsequent writes. so essentially do this:
FileOutputStream fout = new FileOutputStream(filename, false) ;
PrintStream pstr = new PrintStream(fout) ;
pstr.println(tempArray[0]) ;
then:
FileOutputStream fout = new FileOutputStream(filename, true) ;
PrintStream pstr = new PrintStream(fout) ;
// write rest of the content of the array
Thanks.