'Read one line delimited by \'
\' from the file.
A trailing newline character is kept in the string. It may be absent when a
file ends with an incomplete line. If the size argument is non-negative,
it specifies the maximum string size (counting the newline) to return. An
empty string is returned only when EOF is encountered immediately.
Args:
size: Maximum number of bytes to read. If not specified, readline stops
only on \'
\' or EOF.
Returns:
The data read as a string.'

def readline(self, size=(-1)):

    data_list = []
    while True:
        if (size < 0):
            end_pos = len(self._buffer)
        else:
            end_pos = (self._buffer_pos + size)
        newline_pos = self._buffer.find('\n', self._buffer_pos, end_pos)
        if (newline_pos != (-1)):
            data_list.append(self.__readBuffer(((newline_pos + 1) - self._buffer_pos)))
            return ''.join(data_list)
        else:
            result = self.__readBuffer(size)
            data_list.append(result)
            size -= len(result)
            if ((size == 0) or self._eof):
                return ''.join(data_list)
            self.__refillBuffer()
