'readline([size]) -> next line from the file, as a bytes string.
Retain newline.  A non-negative size argument limits the maximum
number of bytes to return (an incomplete line may be returned then).
Return an empty string at EOF.'

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

    if self.closed:
        raise ValueError('I/O    operation    on    closed    file')
    data = ''
    while (('\n' not in data) and ((size < 0) or (len(data) < size))):
        if (size < 0):
            chunk = self.read(1024)
        else:
            chunk = self.read((size - len(data)))
        if (not chunk):
            break
        data += chunk
    if ('\n' in data):
        (data, sep, rest) = data.partition('\n')
        data += sep
        if self.buf:
            self.buf = (rest + self.buf)
        else:
            self.buf = rest
    return data
