from documentation on ios::mode
ios::app:
the content to the current content of the file. This flag can only be used in streams open for output-only operations.All output operations are performed at the end of the file, appending
Remove the ios::app
, and you will be able to write "my"
over "ll"
in `"helloworld".
Note that you won't be able to "insert" something into a file - the only way to achieve that is to read from the original file and write the new data to a new file [or read whatever is after you want to modify, insert the text you want, and write back the parts you want after the modified bit].