Output json to file correctly