@AndrewAMD:
Thanks for the code!
I wonder, does malloc remember how much memory was allocated originally, or does free(str); only free up memory up to the null character, which could potentially lead to a memory leak?
Isn't loading the entire file just to read one line a bit excessive? Perhaps some ideas presented
here could help ease the workload.