Safe way to transfer files between 2 local computers

If I had 2 local computers where 1 computer was an online computer which would have the job of sends and receives encrypted files only, and where the other computer was an offline computer which would only have the job of encrypting and decrypting files, how would I go about transferring files between the 2 computers safely? I am imaging using a USB stick to transfer files between the 2 computers, but would that not run the risk of getting the USB stick infected with some malicious-ware which could possibly expose my private key on the offline computer which is used to decrypt files?

If the USB stick was infected and connected to the offline computer, is it not a possibility that somehow it could find the private key and then when the USB stick is later connected to the online computer, the malicious-ware could broadcast the private key to the author of the malware?

If this is possible, is there a safer way to transfer files between 2 local computers?