using System.IO; StreamReader strIn = File.OpenText(@"toto.txt"); string stCurrentLine = null; while ((stCurrentLine = strIn.ReadLine()) != null) { //do your stuff } File.Copy(@"toto.txt" @"toto.txt" + ".bak", true); StreamWriter strOut = new StreamWriter(@"toto.txt", false, Encoding.Default); strOut.Write(/**/); strOut.Close();