diff --git a/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c
index 96b38d117254e468208ce81f534e1d8a832b7e5e..4bed009411e0865e7356e25b27663d357c1d74cc 100644
--- a/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c
+++ b/src/plugins/accounting_storage/filetxt/filetxt_jobacct_process.c
@@ -1426,7 +1426,7 @@ extern int filetxt_jobacct_process_archive(slurmdb_archive_cond_t *arch_cond)
 	}
 
 	/* reopen new logfile in append mode, since slurmctld may write it */
-	if (freopen(filein, "a", new_logfile) == NULL) {
+	if ((new_logfile = freopen(filein, "a", new_logfile)) == NULL) {
 		perror("reopening new logfile");
 		goto finished2;
 	}