def remove_enclosing_new_line(text):
    """ Return a copy of the string *text* with leading and trailing newline removed.
    """

    i_min = 1 if text[1] == '\n' else 0
    i_max = -1 if text[-1] == '\n' else None

    return text[i_min:i_max]