only write JSON to disk if options.write is true