add 'sync' to end of script

sync ensures that all file writes come out of memory and onto disk