Buffer stdout and stdin