check if file before using isbinaryfile

This is to avoid an error that occurs when calling `isBinary()` with a directory.