diff --git a/config/cfgroot/ids-functions.pl b/config/cfgroot/ids-functions.pl
index c8bc52b1b..dfbeb1a7d 100644
--- a/config/cfgroot/ids-functions.pl
+++ b/config/cfgroot/ids-functions.pl
@@ -393,6 +393,9 @@ sub downloadruleset ($) {
 				return 1;
 			}
 
+			# Remove temporary file, if one exists.
+			unlink("$tmpfile") if (-e "$tmpfile");
+
 			# Increase download attempt counter.
 			$dl_attempt++;
 		}
