Writing to SD Card causes MCU to restart after 12 iterations of the loop

That'll do it. Consider using snprintf instead though - defends against buffer overflow.