def _read_string(f):
    """
    Reads a null-terminated string from a file.
    """

    chars = []
    while True:
        char = f.read(1)
        if char == b'\0':
            break
        chars.append(char)

    return ''.join(chars)