```python
def line_tag(body):
    if not isinstance(body, str):
        raise ValueError("line_tag expects a string")
    return format(sum(ord(ch) for ch in body) % 256, "02x")


def check_line(line):
    if not isinstance(line, str):
        raise ValueError("check_line expects a string")
    if len(line) < 3:
        raise ValueError("check_line expects a line with at least 3 characters")
    if line[-2] != '~':
        raise ValueError("check_line expects a line with a tilde as the third-from-last character")
    tag = line_tag(line[:-2])
    if line[-2:] != tag:
        raise ValueError("check_line expects the body to have the same tag as the line_tag")
    return line[:-2]
```