def indent_string(string, indent='  ', include_first=True, include_last=False):
    """
    Indent a string by adding indent after each newline.
    :param string: The string to indent
    :param indent: The string to use as indentation
    :param include_first: Also indent the first line of the string (before the first newline)
    :param include_last: If the string ends on a newline, also add an indent after that.
    :return: A new string.
    """
    base = string.replace('\n', '\n' + indent)
    if include_first:
        base = indent + base
    if not include_last and base.endswith('\n' + indent):
        base = base[:-len(indent)]
    return base