Writing the json file with results just once