Added check for "fprintf()" on writing pid