Error in printing empty messages in buffer