Fixed EOF detection and handling. If a line is split in the buffer when reading it now waits for the complete line