Duplicate fclose problem fixed