created a way to write the json object to a file