I have about 50 GB of text file and I am checking the first few characters each line and writing those to other files specified for that beginning text.
For example.
Keep it open the whole time! Otherwise you tell the system that you are done writing all the time and it might decide to flush it onto the disk instead of buffering it. And for obvious reasons n disk writes are much more expensive than 1 disk write.
If you want to append to the file and not overwrite it then yes, a
is the correct mode.