def read_until(fd, b):
    """Read bytes from open file object fd until byte b is found"""
    s = b''
    while True:
        c = fd.read(1)
        if not c: break #no more bytes to read
        if c == b: break #found our byte
        s += c
    return s