Only write when there is a new message

Fix later