Change "close(fi)" line 23 to "fclose(fi)"