created a new function to write the json object to a file in the home directory