Hi. Good to hear that at least you are managing to write data correctly. Unfortunately our knowledge with winimage is very limited. You can’t advise you why the file gets corrupt. Maybe you can get a better response from winimage Forum or support.
How are you simulating the SD card with MPLAB X IDE?