To remove the last empty row do the following code:
//Remove last empty row
var csv = message.getNode('/');
csv = StringUtils.substringBeforeLast(csv, '\n');
qie.debug('csv: ' + csv);
message = qie.createTextMessage(csv);
Note: This will be the last mapping. If you convert the message back to a CSV then it will put the empty row back. This means that you can no longer use the message.setNode with a CSV path.