I'm switching a data logger over to C++ (yay!) from spin, but am hitting an odd behavior in the SD card writing bit. I've got a logging switch (on/off) so the user could turn it off, remove the card, insert a new one (or the same really), and turn it back on. I can turn it off/on to my heart's content, but as soon as I remove the card, it's a no go with no further writes occurring. I've simplified it to the program below to demonstrate the issue. I let this run a few loops, then remove the card during the period after the file is closed (and my safe to remove LED is on). Upon reinsertion, no more writes actually happen. Any ideas? Thanks!
sd_mount(19, 20, 21, 22);
FILE* fp = fopen("test.txt", "a");
fwrite("Testing 123...\n", 1, 15, fp);
high(7); // LED for safe to remove ON
print("2 second pause\n");
low(7); // LED for safe to remove OFF