private void transform(String inputFilename, String outputFilename) { char[] fieldsSep = { '\t' }; char[] commaSep = { ',' }; int lineCounter = 0; using (var reader = new StreamReader(inputFilename)) using (var writer = new BinaryWriter(new FileStream(outputFilename, FileMode.CreateNew))) { while (reader.Peek() > -1) { lineCounter++; String line = reader.ReadLine(); if (lineCounter == 4426369) { int a = 4; } UserAction action = UserAction.GetAction(line); if (action == null) { Console.WriteLine("Incorrect line #" + lineCounter + ":\t" + line); continue; } if (!action.WriteToStream(writer)) { Console.WriteLine("IOException in line #" + lineCounter); return; } } } }