JSON and text files, writing JSON