The code does probably work but will take a very long time as it will require a lot of wear leveling effort and potentially cause multiple page erase cycles which will not just take extra time but also cause unnecessary flash wear.
And since that may take even so long that the cloud connection gets temporarily dropped (as it is not serviced during the time) your
Particle.publish() may be failing due to lack of connection.
When you want to debug a certain issue you must make sure that you are not relying on data which in itself may be skewed by other factors and hence lead you to wrong conclusions
Particle.publish() is never a good way to debug your code.
Serial.print() is better but still not perfect for time critical debugging. For that I’d use
digitalWrite() (e.g. on the onboard LED).
However, why would you want to write zeros to EEPROM when this inevitably means the next time you want to write to the same address you need another erase cycle before you can even start writing data?
And if you still wanted, you’d not do it on a byte by byte basis.