Exclude directories in the file list.

The method readdir returns all entries in a directory, including entries that
are directories. Instead of only excluding the '.' and '..' entries, the code
now only returns entries that are files.