import random


def add_random_lines(payload, new_line_probability, verbose):
    """Add random lines into the payload to produce possible broken JSON."""
    # The new payload.
    res = []
    i = 1

    # Iterate over the original payload.
    for line in payload:
        res.append(line)
        # Add wrong line into new payload, but only with some probability.
        if random.random()*100 < new_line_probability:
            if verbose:
                print("    appending error line at position", i)
            res.append("ERROR_LINE\n")
        i += 1
    return res