added file sync at end