Use of JSON.stringify instead of JSON-like string

Script refactored to use JSON.stringify instead of manually constructed
JSON.

Fixes problems with end of lines in Windows (so works fine now in
Mac/Linux and Windows).