using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { //other streamreader code string strTemp = String.Empty; string[] splitsByLine = new string[] { "1, 2, 3, 4", ",,,", "x,y,z", "" }; if (splitsByLine != null && splitsByLine.Any()) { foreach (string s in splitsByLine) { strTemp = s.Replace(",", ""); if (!String.IsNullOrEmpty(strTemp)) { var nameAndSize = s.Split(','); if (nameAndSize != null && nameAndSize.Any() && nameAndSize.Count() > 1) { Console.WriteLine(String.Concat(nameAndSize[0])); } } } } } } }