For short files, the easiest way would be to read in the contents of the file, update it and then write out the new contents.

If you want to update the bytes of the file directly, the...