diff --git a/library/Core.cpp b/library/Core.cpp index 1b8d5388f..82c8c7933 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -500,19 +500,22 @@ static void loadScriptFile(Core *core, PluginManager *plug_mgr, string fname) { core->con << "Loading script at " << fname << std::endl; ifstream script(fname); - if (script.bad()) + if (script.good()) { - core->con.printerr("Error loading script\n"); - return; + int tmp = 0; + string command; + while (getline(script, command)) + { + if (!command.empty()) + runInteractiveCommand(core, plug_mgr, tmp, command); + } } - - int tmp = 0; - string command; - while (getline(script, command)) + else { - if (!command.empty()) - runInteractiveCommand(core, plug_mgr, tmp, command); + core->con.printerr("Error loading script\n"); } + + script.close(); } // A thread function... for the interactive console.