chapter 5: basic stream implementation
chapter 5: exercise 1