Getting two Arduinos to talk to each other via an optocoupler I've setup two Arduinos connected via an optocoupler on a breadboard.

One Arduino is a sender and sends pulses to the optocoupler causing the diode to turn on.

When this happens the other Arduino has it's input connected to the emitter. This is interpreted as 1 on the receiver side. Or if the diode is off it's a 0 on the receiver side.

My problem is getting them to sync. I'm currently using delay which I'm starting to realize is a horrible idea since they go out of sync after about 2 characters have been sent. So I wonder are there any better solutions to syncing them?
In order to synchronize two deices transmitting any information you need a CLK signal. CLK stands for clock so basically you send a 1 each time you want to send a bit of data. But in order to do so you need one more wire and a CLK generator (usually the transmitter). 
It is described very well in the video of Ben Eater about Reliable data transmission. So I recommend you watching the video since Ben covers a lot of important topics on data transmission and shows a arduino example of how to transmit and receive data properly.