Claro, en el principio del archivo, perdón; estás utilizando w+ y como consecuencia se borra el antiguo archivo y se crea uno con el mismo nombre. w+:
Create an empty file for both reading and writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.
Debes hacerlo con r+.