Hi:
The communication link between Arduino and computer is being lost or corrupted somehow. These are possible reasons:
-Check and/or replace the USB cable, could be deffective.
-Check for strong sources of interference close to your system, such as big AC motors, compressors, etc.
-Plug you system into a different outlet.
-Move the realy you are actuating a few feet away from Arduino and USB cable. The sparking in the contacts could be interfering. You are switching 220 VAC with a light bulb which is a heavy load. This creates heavy sparking in the realy contacts. When the contacts close and open they spark and radiate Electromagnetic Interference (EMI) maybe strong enough to interfere with your system communication link. There are methods to reduce EMI.
-Check the USB connector is not introducing faulty contacts when you move the cable.
Adrian