﻿using System;
using System.IO;
class LineNumbers
{
    static void Main(string[] args)
    {

        //Write a program that reads a text file and inserts line numbers in front of each of its lines.
        //The result should be written to another text file.

        try
        {
            using (StreamReader stream = new StreamReader(@"..\..\..\txt\Odd.txt"))
            {
                StreamWriter outputStream = new StreamWriter(@"..\..\..\txt\ResultFromNumbering.txt");
                string[] allLinesFirstStream = stream.ReadToEnd().Split('\n');
                for (int line = 0; line < allLinesFirstStream.Length; line++)
                {
                    outputStream.WriteLine("{0}{1}", line + 1, allLinesFirstStream[line]);
                }
                outputStream.Close();
            }
        }
        catch (DirectoryNotFoundException exception)
        {
            Console.WriteLine(exception.Message);
        }
        catch (FileNotFoundException exception)
        {
            Console.WriteLine(exception.Message);
        }
        catch (FileLoadException exception)
        {
            Console.WriteLine(exception.Message);
        }
        catch (EndOfStreamException exception)
        {
            Console.WriteLine(exception.Message);
        }
    }
}
