It's a bug in your implementation of takeLine I believe. It doesn't take into account that lines can span multiple chunks. When you call takeLine the first time, you get "L1\n". leftover puts a chunk with exactly those contents back. When you call takeLine the second time, it gets the chunk "L1\n", and your splitAt gives you back "L1\n" and "". The "" is then leftover, and the next call to takeLine gets it.
Your takeLine needs to include logic saying "there's no newline in this chunk at all, let's get the next chunk and try that." You can look at the source to lines[1] for an example of the concept.
Michael