def METHOD_NAME(self, stream):
    try:
        line = next(stream)
    except StopIteration:
        raise ValueError("Empty file.") from None
    if line.strip() != "#NEXUS":
        raise ValueError("File does not start with NEXUS header.")