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