If you load the entire file into a string, you can probably use the method described in this question . This way you can get the file size in bytes and highlight your line to hold it (don't forget the extra byte for the null character).
However, if you dynamically enlarge a string, it is better to increase its size by a factor exceeding one byte (redistributing the string each byte will be very slow, especially if the string should be allocated to a new memory area and then copied). Since you are reading file doubling, this is probably very reasonable. I also saw that people use other methods, for example:
I saw people with the following power of 2, for example 2, 4, 8, and then 16 bytes. (which essentially doubles the file size each time).
, , , , .. 100 .
, .