Reducing scope of stdout side-effects