def openappend(file):
    """Open as append if exists, write if not."""
    try:
        output = open(file, 'a')
    except Exception:
        try:
            output = open(file, 'w')
        except Exception:
            return 'error'
    return output
