string path = @"...";string line = String.Empty;while((line = reader.ReadLine()) != null) List<string> lst = File.ReadAllLines("Data.txt") .Where(arg => !string .IsNullOrWhiteSpace(arg)) .ToList(); lst.RemoveAll(x => x.Split('.')[0].Equals(name)); File.WriteAllLines(path, lst);}