def determine_device(kal_out):
    """Extract and return device from scan results."""
    device = ""
    while device == "":
        for line in kal_out.splitlines():
            line = line.decode("utf-8")
            if "Using device " in line:
                device = str(line.split(' ', 2)[-1])
        if device == "":
            device = None
    return device