improved writing of analysis to output