def striplines(text):
    """ Remove all leading/trailing whitespaces from lines and blank lines. """
    return "\n".join(
        line.strip() for line in text.splitlines() if len(line.strip())
    )