def indent(string, indent):
    """
    Indents each line of a string.
    """
    return (
        "\n".join( indent + l for l in string.splitlines() ) 
        + ("\n" if string.endswith("\n") else ""))