1. There is a SPIFFS.begin in setup and there is also one somewhere else.
2. Listen() is called both inside an if as well as outside it::
// Disable listen function prior to writing data to log file
if (!((((MINUTE) == 14)||
((MINUTE) == 29)||
((MINUTE) == 44)||
((MINUTE) == 59))
&& ((MINUTE) > 50)))
{
listen();
}
listen();
More generally, now that it works, I would strongly suggest that you 'tidy' it - by tidy I don't mean cosmetic, I mean try to modularise the functionality and get rid of some of those globals, and various state flags here and there.
You might be worth looking at your choice of opening spiffs files here and there, and instead open the regular log file at startup. Consider file i/o (and serial i/o prints for that matter) to be very costly in terms of real-time performance and how that might affectect current or future functioning of your software.
There are a number of functions in the webserver library which provide common http formatting responses etc, you may find some of your code can be replaced by it.