Safer way to check if a path is a file

Directories can contain `.` too.
Merge pull request #216 from kevva/is-file

Safer way to check if a path is a file