utils.rb:which: bug fix

Before the proposed change, `which('foo')` would mistakenly return any *directory* of the form `/some/path/foo` that came ahead of the executable *file* `/some/other/path/foo` in the search path.  The reason is that it is not enough to test that a given path is executable; it must also not be a directory.

Note: I'm not a ruby programmer; there are probably better ways to do this.