you have used

tempFile.open( "abc.txt" );

to open file
you have not given read, write i. e. w, r, +w etc. mode of open file...
i think by default it takes "w" mode which delete existing data of file and start writing it from 0th byte...........

try by using "+w" mode..............................