writing output of topic detection