Given that the word you want to replace is <= length than what you want to replace, one solution is file-mapping. Otherwise, you generally you have to use a temp file.

Kuphryn