Writing json data to file