Fix for JSON parsing error caused by separator occurring in the middle of a data chunk

I ran into an intermittent issue in `script.js` where the separator was being included in the data sent to the `onExit` handler. The cause was that the separator was not the last character in the chunk, therefore the algorithm that excluded the last character in the chunk was missing the separator.

There is a node module designed to help with this exact problem, so this pull request uses that module. After this fix, I am no longer seeing intermittent JSON parsing errors.