fat16lib vs SD standard library

It's worse than any of the above. If I didn't call sync, whole file is lost and the file system is corrupt since all the clusters in the file have been marked as allocated. Only sync() or close() update the directory entry with the file size.

If I had put

SdFile file;

inside setup like this

void setup() {
  SdFile file;

The file would be closed when setup ends, at least in the new beta version of SdFat, because the destructor is:

  ~SdFile() {close();}

This is why the "Arduino team" decided to set the O_SYNC flag in their SD.h wrapper for SdFat. This causes sync() to be called after every byte with print since print does single character writes. SD.h is a killer or at least an extreme test for the SD flash controller.

Many applications write a "record" of data and then call sync(). I just can't automatically do the "right thing" in the library.