C# error (on monitoring bytes received/sent) [edited]
<p>I would like to monitor the bytes that were sent and received by an RFID reader. But this thing doesn't compile. :(
It says it lacks '}' however if I put one, transportLogFile (on function SerialListener) is not recognized. 
What's wrong with this? </p>

<p>Copyright (c) 2009 ThingMagic, Inc.</p>

<pre><code>   using System; // system namespace reserved for items associated with .NET Framework class library
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Data;
using System.Threading;
using ThingMagic;


namespace Read_v5
{
    class Program
    {
        private TextWriter transportLogFile;
        static void Main(string[] args)
        {
            TextWriter transportLogFile;
            StreamWriter writer = new StreamWriter("log.txt");
            writer.AutoFlush = true;
            transportLogFile = writer;
            using (Reader rdr = Reader.Create("tmr:///com29"))
            {
                if (rdr is SerialReader)
                    rdr.Transport += TimestampListener;

                SimpleReadPlan readplan = new SimpleReadPlan();
                rdr.Connect(); //establish connection
                rdr.ParamSet("/reader/region/id", Reader.Region.OPEN); //region set in OPEN
                rdr.ParamSet("/reader/read/plan", readplan);
                int[] antennas = (int[])rdr.ParamGet("/reader/antenna/connectedPortList");
                rdr.ParamSet("/reader/tagop/antenna", 1);
                rdr.ParamSet("/reader/tagop/protocol", TagProtocol.GEN2);
                //   Console.WriteLine(rdr.ParamGet("/reader/tagop/antenna"));
                //   Console.WriteLine(rdr.ParamGet("/reader/tagop/protocol"));
                //  Console.WriteLine(" " + rdr.ParamGet("/reader/antenna/portList"));
                //   rdr.ParamSet("/reader/antenna/txRxMap", new int[][]{new int[]{1,1,1}});
                readplan.Antennas = new int[] { 1 };
                //    Console.WriteLine(" " + rdr.ParamGet("/reader/antenna/portList").ToString());
                readplan.Protocol = TagProtocol.GEN2;
                //      Console.WriteLine(rdr.ParamGet("/reader/antenna/portList"));
                rdr.ParamSet("/reader/read/asyncOffTime", 100);
                rdr.ParamSet("/reader/read/asyncOnTime", 500);
                rdr.StartReading();
                //     Console.WriteLine("FIN");
                //     int y = 0;
                while (rdr.Equals(rdr))
                {

                    //  Console.WriteLine("\r\n&lt;Do this\r\n");
                    rdr.TagRead += delegate(Object sender, TagReadDataEventArgs e)
                    {
                        Console.WriteLine("EPC: " + e.TagReadData.EpcString);
                        Console.WriteLine("RSSI: " + e.TagReadData.Rssi.ToString());
                        Console.WriteLine("Phase: " + e.TagReadData.Phase.ToString());
                    };
                    Thread.Sleep(200);

                }
                rdr.StopReading();
                rdr.Destroy();
                transportLogFile.Close();
            }
        }
        private void TimestampListener(Object sender, TransportListenerEventArgs e)
        {
         //   TextWriter transportLogFile = null;
            transportLogFile.Write(String.Format("{0} {1}",
                DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss.fff tt"),
                e.Tx ? "Sending" : "Received"));
            for (int i = 0; i &lt; e.Data.Length; i++)
            {
                if ((i &amp; 15) == 0)
                {
                    transportLogFile.WriteLine();
                    transportLogFile.Write("  ");
                }
                transportLogFile.Write("  " + e.Data[i].ToString("X2"));
            }
            transportLogFile.WriteLine();
        }

    }

}
</code></pre>
