Added back check for a null cursor in WriteStream.prototype.insertScript