fix bug where multiple input sources corrupted the json file.