Move stdin/stdout to subclasses

Prepare for some refactoring to support unformatted files.