diff --git a/src/cats/command_line/command_line_options.c b/src/cats/command_line/command_line_options.c
index d49f242f367316dab1b3917ab53c14998e67ce4c..88c30cbeebfa2f6284a0d8927b4d99937240cf8c 100644
--- a/src/cats/command_line/command_line_options.c
+++ b/src/cats/command_line/command_line_options.c
@@ -24,6 +24,7 @@
 #include "cats_global.h"
 
 #include <string.h>
+#include <assert.h>
 #include "command_line_options.h"
 #include "command_line_info.h"
 
@@ -91,17 +92,17 @@ struct program_options check_cats_main_arguments(int argc, char **argv)
         int opt;
 
         int error = 0;
-
+        int option_index = 0;
         // FIXME unify error messages, start with Error:
         while ((opt = getopt_long(argc, argv, "qs:r:l:v:ho:",
-                                  longopts, &optind)) != -1) {
+                                  longopts, &option_index)) != -1) {
 
                 bool success;
                 bool conversion_success;
                 float value;
                 bool bool_value;
                 switch (opt) {
-                        case 'o':
+                         case 'o':
                                 options.output_directory = strdup(optarg);
                                 break;
                         case 'r':
@@ -288,9 +289,9 @@ struct program_options check_cats_main_arguments(int argc, char **argv)
                 exit_cats(EXIT_FAILURE);
         }
 
-        for (int index = optind; index < argc; index++) {
-                options.configuration_file = argv[index];
-                break;
+        assert(optind < argc);
+        if (options.configuration_file == NULL && options.need_conf == true) {
+                options.configuration_file = strdup(argv[optind]);
         }
 
         if (options.configuration_file == NULL && options.need_conf == true) {