diff --git a/src/Main.cpp b/src/Main.cpp
index 1beeba8..ff86a1f 100644
--- a/src/Main.cpp
+++ b/src/Main.cpp
@@ -163,6 +163,7 @@ bool WriteFile(const char* pFileName, const uint8_t* pData, size_t size)
     return true;
 }
 
+static bool end_of_switches = 0;
 int main(int argCount, char** args)
 {
     if (argCount < 2)
@@ -194,7 +195,8 @@ int main(int argCount, char** args)
         {"-e",   [&]() { options.endMarker = 1; }},
         {"-o",   [&]() { options.extendOffset = 1; }},
         {"-l",   [&]() { options.extendLength = 1; }},
-        {"-n",   [&]() { options.naturalStream = 1; }}
+        {"-n",   [&]() { options.naturalStream = 1; }},
+        {"--",   [&]() { end_of_switches = 1; }},
     };
 
     // Process command line arguments.
@@ -203,26 +205,23 @@ int main(int argCount, char** args)
 
     for (int i = 1; i < argCount; i++)
     {
-        if (inputName.empty())
+        if (args[i][0] == '-' && ! end_of_switches)
         {
-            if (args[i][0] == '-')
+            auto iAction = actions.find(args[i]);
+            if (iAction != actions.end())
             {
-                auto iAction = actions.find(args[i]);
-                if (iAction != actions.end())
-                {
-                    iAction->second();
-                }
-                else
-                {
-                    PrintError(ErrorId::InvalidParam, args[i]);
-                    return 1;
-                }
+                iAction->second();
             }
             else
             {
-                inputName = args[i];
+                PrintError(ErrorId::InvalidParam, args[i]);
+                return 1;
             }
         }
+        else if (inputName.empty())
+        {
+            inputName = args[i];
+        }
         else if (outputName.empty())
         {
             outputName = args[i];
