After each newline, you are the "device" in the middle that unplugs the USB from the source computer and plugs it in to the destination computer.
Now we want to automate the middle, but without networking. How to do that?
See also Logitech Flow keyboard (and mouse). After each batch of commands, communicate via the shared clipboard.