fix os.write and sort