better handling of first write to json file