write csv only if there is some output data present