Replacing 'write(dumps())' with 'write_json()'