// main routine for balanced symbol checker.
    // Slightly different from text.
    // If no command line parameters, standard input is used.
    // Otherwise, files in command line are used.
    public static void Main(string[] args)
    {
        Balance p;

        if (args.Length == 0)
        {
            p = new Balance(Console.In);
            if (p.CheckBalance( ) == 0)
            {
                Console.WriteLine("No errors!");
            }
            return;
        }

        for (int i = 0; i < args.Length; i++)
        {
            TextReader f = null;
            try
            {
                f = new StreamReader(args[i]);

                Console.WriteLine(args[i] + ": ");
                p = new Balance(f);
                if (p.CheckBalance( ) == 0)
                {
                    Console.WriteLine("   ...no errors!");
                }
            }
            catch (IOException e)
            {
                Console.Error.WriteLine(e + args[i]);
            }
            finally
            {
                if (f != null)
                {
                    f.Close( );
                }
            }
        }
    }