def add_line_prefix(text, prefix, num_start=None):
    """Add a prefix before each line of the given text.

    Usage:
    >>> _add_line_prefix('This\nis\nmultiline', '+ ')
    <<< + This
    <<< + is
    <<< + multiline

    >>> _add_line_prefix('This\nis\nmultiline', '+ ', 9)
    <<<  9 + This
    <<< 10 + is
    <<< 11 + multiline

    Note that numbers are padded to the longest num of digits, e.g.
    #   9
    #  99
    # 999

    :param unicode text: the original text
    :param unicode prefix: the prefix to add
    :param int num_start: the number of the first line
    :return: the new string
    :rtype: unicode
    """
    if not text:
        return text

    lines = []
    split_lines = text.splitlines(True)
    total_lines = len(split_lines)
    for n, line in enumerate(split_lines):
        lines.append(
            '{line_num}{prefix}{line}'.format(
                line_num=(
                    '{} '.format(num_start + n).rjust(  # rjust adds padding
                        len(str(total_lines)))
                    if num_start is not None
                    else ''
                ),
                prefix=prefix,
                line=line,
            )
        )
    return ''.join(lines)