fix compiler warning

fgets return type is (char *) and returns either the buffer or NULL on error.
The code looks as it is expecting that an integer is returned with -1
representing an error.  This triggers a warning with gcc's -Wpedantic enabled
(see ticket).

This patch checks whether returned value is NULL.

Ticket: http://rt.dcache.org/Ticket/Display.html?id=8319