Fixed issue with while loop running forever because of recursive calls

This pull addresses a problem where the get_next_line function could run forever if it failed to read a line.