My program stores a log for the user. If the log is ever larger than the set amount, I want to delete the first 20% of the lines.
From similar questions, I saw suggestions for reading in the old file and write out all the lines that I want to save in the new file. However, my files may be too large to be read continuously, and using this method would not allow me to keep the same file name.
Is it possible to delete lines from a file without reading in my old file?
source share