You’ve included both “SD.h” and “SdFat.h”. Did you try including only one of those? They might not conflict for the compiler, but they have very similar functionality and shouldn’t be included together. Your code is written for SD. SdFat is better, but for what you’re doing it shouldn’t matter.