<p>How do I use the ofstream to write text to the end of a file without erasing its content inside?</p>

You can pass the flag
```
ios::app
```
when opening the file:
```
```
ofstream ofs("filename", ios::app);
```
```