The issue is that checking
and saving
only exist for the duration of a single call to transactions()
.
They spring into existence when transactions()
is called, get initialized, your code changes them, and they disappear the moment transactions()
returns. When the function is called again, the whole cycle repeats.
The two variables need to exist outside the function (probably as data members of some class).