support output in both txt and rtf format