I wanted to edit just the first line of a 4 MB file. When I open files this large in gedit, it takes a minute or two to load the file but displays and allows you to edit the part that it has loaded so far. So I opened the file, quickly edited the first line, saved the file, and closed gedit all before it was even close to finishing loading the file.
How was it able to save the file before loading it completely? The only way I know of editing files is to load it into memory, edit the copy in memory, then write the whole thing back to the file.