It sounds like you're running into a common problem people have with E-Prime: understanding the difference between variables and attributes. By defining something in the user script, you're declaring it as a variable, not an attribute. Attributes show up in lists and data files; variables don't. You also seem to have a scope issue on the attribute, which is making things more complicated.
What's confusing here is that E-Prime is trying to help you out by creating attributes when you use c.setattrib -- so you now have a total_n attribute as well as a variable, and that's what gets logged in the data file. But that attrbiute only exists in the lowest-level list that's running when E-Prime creates it. I would guess that your attempt to display the counts is outside that list. Alternatively, if you didn't fall into that trap, you're trying to use the variable, which you've actually never assigned a value to.
The first thing to try is to create an attribute in the list that's above the one you're setting the value in (the list that's running when you try to display the value at the end), and then let it set the value in that list. Or you could just keep track of those totals in the global variable you already have (if you don't care about logging as you go) and then log them in an inline after the list.
HTH,
Susan