write(2) and close(2) doesn't ensure the file content actually got synched, so let's also fsync before doing the rename