Problem with directory listings after other file IO

First of all, the example code that prints out a directory does not close the files that it opens up.

So, fix the example. It was never stated that it was perfect. It was provided to illustrate how to do something.