The problem is that you open and close the file multiple times and each time you open the file you destroy the contents that were there previously.
Probably you should open the file once only in the constructor (and don't close the file there).
An alternative would be to open the file in 'append' mode, but that would be very inefficient, opening a file is an expensive operation. As Liho suggested
ofsFile.open("/home/user/example.txt", std::ofstream::out | std::ofstream::app);