Merge pull request #899 from ey6es/master

Fix for compile warnings on Linux: check return values on read/write.