I'm writing a code which takes one file and saves it into another with a different name - however, I am not sure whether or not I need to fclose both files or not?
FILE *logfile = fopen("log.txt", "a+");
while(1) {
char filename[500];
char logline[512];
char channel[512];
//Do stuff
sprintf(filename, "%s.log.txt", channel);
freopen(filename, "a+", logfile);
log_to_file(logline, logfile);
}