from pathlib import Path


def check_file(file: str):
    """Check file exists."""
    file_path = Path(file)

    if not file.endswith((".cfg", ".txt", ".log")):
        raise ValueError(f"{file_path} must end with '.cfg', '.txt' or '.log'")
    if not file_path.exists():
        raise SystemExit(f"{file_path} doesn't exist.")
    return file