'Read and return a line from the stream.
If limit is specified, at most limit bytes will be read.'

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

    if ((not self._universal) and (limit < 0)):
        i = (self._readbuffer.find('\n', self._offset) + 1)
        if (i > 0):
            line = self._readbuffer[self._offset:i]
            self._offset = i
            return line
    if (not self._universal):
        return io.BufferedIOBase.readline(self, limit)
    else:
        line = ''
        while ((limit < 0) or (len(line) < limit)):
            readahead = self.peek(2)
            if (readahead == ''):
                return line
            match = self.PATTERN.search(readahead)
            newline = match.group('newline')
            if (newline is not None):
                if (self.newlines is None):
                    self.newlines = []
                if (newline not in self.newlines):
                    self.newlines.append(newline)
                self._offset += len(newline)
                return (line + '\n')
            chunk = match.group('chunk')
            if (limit >= 0):
                chunk = chunk[:(limit - len(line))]
            self._offset += len(chunk)
            line += chunk
        return line
