modified fclose(fp);