diff --git a/src/main.c b/src/main.c
index 2a3fd6f43cb39b0f4d648e1c2d9d68e98a27ba49..33d40d56a1f1570e1a7a97d98ea5fad1a2552b01 100644
--- a/src/main.c
+++ b/src/main.c
@@ -130,7 +130,9 @@ parse_commands_file (struct WpDaemonData *d, GInputStream * stream,
         /* tokenize and execute */
         cmd = strtok_r (linestart, " ", &saveptr);
 
-        if (!g_strcmp0 (cmd, "load-module")) {
+        if (!cmd || cmd[0] == '#') {
+          /* empty line or comment, skip */
+        } else if (!g_strcmp0 (cmd, "load-module")) {
           abi = strtok_r (NULL, " ", &saveptr);
           module = strtok_r (NULL, " ", &saveptr);