Your choices are:
- Create a new file, write the new data and copy the old data to the new file, then replace (the contents of) the old file with the new file.
- Read a block from the end of the file, write the block to its new position, repeatedly, working your way backwards through the file.
The advantage of (2) is that it doesn't break symlinks or multiple links to the original file. The disadvantage (as noted by Keith Thompson) is that if it is interrupted, you've lost your original file.
The disadvantage of (1) is that if you need to preserve numbers of links and work through symlinks, you have to copy the new file back over the old file, so there's more copying. The advantage is that the copying is simpler and the original file is not destroyed until the end.
There's another question with code for option (2) — Write in the middle of a binary file without overwriting any existing content. Inserting at the start of a (binary) file is just a specific (not even special) case of inserting in the middle of a file.