check if file before using isbinaryfile

This is to avoid an error that occurs when calling `isBinary()` with a directory.

I'm also going to see about making a PR for [gjtorikian/isBinaryFile](https://github.com/gjtorikian/isBinaryFile) too but that's going to take me a bit longer.