Write json output to file