SD card file write is skipping data

you want to call sync() to flush the data rather than closing. Close does call sync ... but it closes as well which is the bit you don't want.

Look at the SD library code to see about sync().