Why is it that using a total will cause Progress to process the code, even though it doesn't meet the condition?

def var yesno as log no-undo.
def stream s_file.

def temp-table t-table
field name as char
field age  as int.

create t-table.
  name = "Bob"
  age = 44.

if yesno then
  output stream s_file to terminal.

for each t-table break by name:

  if yesno then
    display stream s_file
    age(total by name)
    with frame a.

This throws the error ** Attempt to write to closed stream s_file. (1387)

if I replace age(total by name) with just age or remove it entirely, things work okay.

This is just a simplistic isolated example of a problem I am having. Don't think too much into why someone would want to total age. :/