using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace Replace
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Error: Expected Replace fileName searchText replacedText.");
            }
            StreamReader sr = new StreamReader(args[0]);
            string all = sr.ReadToEnd();
            sr.Close();

            all = all.Replace(args[1], args[2]);

            var sw = new StreamWriter(args[0], false);
            sw.Write(all);
            sw.Close();
        }
    }
}
