def read_file_first_line(fname: str) -> str:
    """Read the first line of the given file to a string (removing a single trailing newline if
    one is present)"""

    with open(fname, encoding="utf8", errors="surrogatescape") as file:
        line = file.readline()

    return line[:-1] if line.endswith("\n") else line