Fix: freed and closed file pointers.