ESP32 SPIFFS data corruption

I have some odd behaviour, which replicates on different boards (ESP32s and ESP32-CAM).
I am taking temperature and humidity data, saving it to SPIFFS (at a certain time interval) and the SPIFFS file is read (at some time interval) and served to a website.

I don’t think any of my code is much wrong because it works fine for the first 600 or so readings. But, when the numbers get higher the website console complains that the JSON file is not valid.
When I Serial print out what is being sent it is indeed mangled, and very much shorter.

Each data set looks like this ,{“TI”:“18.1”,“TO”:“18.2”,“HI”:“61.3”,“HO”:“60.6”} and using a JSON online facility I have seen that 500 entries are about 20KB, so well short of the 1.4MB that the default partition is set to.

I have run out of ideas and would appreciate if anyone with better knowledge of SPIFFS can point me in the right direction.

edit: I have watched as it added data and at 799 entries it threw an unhandled exception and reset. Perhaps my program variables need looking at. So I’m guessing the corruption comes from crashing out during a write.

edit: Not the crashing thing but maybe I have too much data to fit in a String variable, look like I can’t exceed 4000bytes ?