When writing session data to stdout or stderr, switch the relevant file