Checking for error when opening file descriptor

Closes https://github.com/PistonDevelopers/hematite/issues/153