write text and json to separate files