which() should only find files, not directories

This pull request fixes that