diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C
index 7b204e984f0843a295081809537982afea41f845..117d5283a5829a041489fab37377c9c82bd566a3 100644
--- a/applications/utilities/mesh/manipulation/setSet/setSet.C
+++ b/applications/utilities/mesh/manipulation/setSet/setSet.C
@@ -934,18 +934,31 @@ int main(int argc, char *argv[])
                 {
                     char* linePtr = readline("readline>");
 
-                    rawLine = string(linePtr);
+                    if (linePtr)
+                    {
+                        rawLine = string(linePtr);
+
+                        if (*linePtr)
+                        {
+                            add_history(linePtr);
+                            write_history(historyFile);
+                        }
 
-                    if (*linePtr)
+                        free(linePtr);   // readline uses malloc, not new.
+                    }
+                    else
                     {
-                        add_history(linePtr);
-                        write_history(historyFile);
+                        break;
                     }
-
-                    free(linePtr);   // readline uses malloc, not new.
                 }
 #               else
                 {
+                    if (!std::cin.good())
+                    {
+                        Info<< "End of cin" << endl;
+                        // No error.
+                        break;
+                    }
                     Info<< "Command>" << flush;
                     std::getline(std::cin, rawLine);
                 }