public static List <Snack> ReadSnackFile(string filename) //reads from text file { List <Snack> snack = new List <Snack>(); StreamReader sr = null; try { sr = new StreamReader(filename); while (!sr.EndOfStream) { string line = sr.ReadLine(); string[] tokens = line.Split('\t'); string name = tokens[0]; double price = double.Parse(tokens[1]); string category = tokens[2]; string descrip = tokens[3]; string taste = tokens[4]; Snack p = new Snack(name, price, category, descrip, taste); snack.Add(p); } } catch (Exception) { Console.WriteLine("Error reading file"); } finally { if (sr != null) { sr.Close(); } } return(snack); }