added a missing fclose and adding temp.bin files every interval (set in problem.c) for temporary saves