I wrote a crappy get_next_line and then improved it so it's no longer crappy.
Get_next_line is a function that gets one line from a file descriptor on each call. It keeps a buffer with the data it already read and will return the next line on each call.