Attempt number 2

Let's try not to hold everything in memory. If the total length of the buffer
is twice the size of what is left to be read we can discard this. It's
arbitrary but it's just throwing something at the wall.