How do I protect SD card against unexpected power failures?
A few things can happen when you write data to a file. I'm going to describe the sequence that needs to happen for data to be safe, not necessarily library calls.

When you're writing, and adding on to the end of the file (normal write mode), you read the last block of the file into memory, modify it with your write data, and then write the whole block back to the SD card. If the block is full, then a new block must be found in the File Allocation Table (FAT). After finding a new block, the FAT must be updated, which is a read-modify-write cycle. If we're done with the file, then we need to update the file attributes (such as file length) in the root directory, which causes another read-modify-write cycle.

Minimizing your write time


Make sure that the file is already holding your data when you write a sector. If you start out with a large file and overwrite the data instead of appending the data, the data will be safe as soon as the SD card sector write is finished. You can eliminate one to two read-modify-write cycles that way. My start-up code would write 0's to a file in sector increments until the SD card is full, and then rewind to the beginning of the file.
Make the size of your data entries such that an integer number of entries fit in a sector. I would bump up your entries to 64 bytes. While this is less efficient, it will prevent you from needing to read-modify-write two sectors.
Create a variant of the FSwrite function that allows you to write whole sectors. If you keep the whole sector in SRAM, then your cycle goes from "read-modify-write" to "modify-write"


Keep your PIC and SD power on as long as possible


Big capacitors are good. 470uF should give you more than enough power to finish a write cycle.
Make sure your power source won't suck the power out of your back-up capacitor! Add a diode if necessary.


Know when you're out of power


A big power supply cap will give you 10ms or more to wrap things up with a SD card, but don't press your luck. Use a pin on your microcontroller to see if your power source is still good, and don't start a write if your source is dead.