check realpath, fgets return value