Add sync() calls to force physical write to SD.