fixed json file writing