Fixed bug in C++ version

Output file was not written at the end of the simulation.
This is the same bug fixed in the version of simplemd
embedded in plumed2, see plumed/plumed2@7659e810471a57ec1