def scrap(consensus, end_of_field):
    """
        Consume lines upon matching a criterion.

        Returns (consensus-without-first-line, first-line)
            if end_of_field(first-line) returns True,
            else returns (consensus-with-first-line, None)

        :param bytes consensus: input which first line may be consumed
        :param function end_of_field: passed a line, returns True when no match

        :returns: a tuple (updated-consensus, next-field-or-None)
    """
    if b'\n' not in consensus:
        return consensus, None

    line, remaining = consensus.split(b'\n', 1)
    if end_of_field(line):
        return consensus, None
    return remaining, line