Checking for error when opening file descriptor

Closes https://github.com/PistonDevelopers/hematite/issues/153
Merge pull request #154 from bvssvni/master

Checking for error when opening file descriptor