FileStream.SetLength
using System; using System.IO; public class StrmWrtr { static public void Main (string [] args) { FileStream strm; StreamWriter writer; strm = new FileStream ("text.txt", FileMode.OpenOrCreate, FileAccess.Write); writer = new StreamWriter (strm); strm.SetLength (0); while (true) { string str = Console.ReadLine (); if (str.Length == 0) break; writer.WriteLine (str); } writer.Close (); strm.Close (); } }