was not waiting for eeprom to be ready before trying to write again, causing failure. was also a bug in the write routine.