Add more informative file read/write error check in sysfs.c

Now, the code checks for errors both, when opening as well as when closing the file.
Some of the "invalid argument" errors and other similar ones, which earlier could not be
detected will now be written to stderr.
The original, slightly uninformative error check is now replaced by perror() which will print
the actual error message, according to errno.