, :
1) read the contents of the file you need to change
2) change the content (as a string, if you have content in a variable called content), for example: content = header + content
3) tend to the beginning of the file, each language has a search method or equivalent search
4) write new content
5) crop the file at the position returned by the file pointer
There you have it, there is no temporary file. :)
source
share