Yet another tweak on writeMessage().
Should function nicely now.