I agree that it is best to be able to tell the OS exactly what you want to do, though sometimes that can be tricky.
In the case of modifying a file, if it really is just a few bytes in the middle that you want to change, then getting a lock, writing those bytes, and unlocking is probably best.
However in many cases you want to change N bytes in the middle of the file to M other bytes. This either requires non-linear transformations on the file, or the remainder of the file to be re-written. The former would hardly ever by used and so would be buggy. The later is very little less effort than re-writing the entire file.
So I still think that 'write a new file and replace the old' is a good model to follow.