diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index e6ddb5b739..10071a0d34 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -423,14 +423,16 @@ namespace OpenSim { m_log.Info("[COMMANDFILE]: Running " + fileName); - StreamReader readFile = File.OpenText(fileName); - string currentCommand; - while ((currentCommand = readFile.ReadLine()) != null) + using (StreamReader readFile = File.OpenText(fileName)) { - if (currentCommand != String.Empty) + string currentCommand; + while ((currentCommand = readFile.ReadLine()) != null) { - m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); - m_console.RunCommand(currentCommand); + if (currentCommand != String.Empty) + { + m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); + m_console.RunCommand(currentCommand); + } } } }