How to calculate Splitting the Bill in C# from a text file (expenses.txt) and write output to a new text file (expenses.txt.out)?
A number of friends go camping every year at provincial parks.

The group agrees in advance to share expenses equally, but it is not practical to have them share every expense as it occurs. So individuals in the group pay for particular things, like food, drinks, supplies, the camp site, parking, etc. After the camping trip, each personís expenses are tallied and money is exchanged so that the net cost to each is the same. Read from a list of expenses, the amount of money that each person must pay or be paid.

Sample Input:
3 (# of people)
2 (# of bills for the 1st person)
10.00 (Amount paid by 1st person)
20.00 (Amount paid by 1st person)
4 (# of bills for the 2nd person)
15.00 (Amount paid by 2nd person)
15.01 (Amount paid by 2nd person)
3.00 (Amount paid by 2nd person)
3.01(Amount for the 2nd person)
3 (# of bills for the 3rd person)
5.00 (Amount paid by 3rd person)
9.00 (Amount paid by 3rd person)
4.00 (Amount paid by 3rd person)

2 (# of people)
2 (# of bills for the 1st person)
8.00 (Amount paid by 1st person)
6.00 (Amount paid by 1st person)
2 (# of bills for the 2nd person)
9.20 (Amount paid by 2nd person)
6.75 (Amount paid by 2nd person)
0 End of program

Output for Sample Input


This is what I tried So far-. But how would I distinguish people, bills and amount in this case?
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.IO;

namespace SplittingTheBill
    class Program
        static void Main(string[] args)
                //Pass the file path and file name to the StreamReader constructor
                StreamReader sr = new StreamReader("C:\\Users\\makhtar\\Desktop\\P S\\SplittingTheBill\\SplittingTheBill\\expenses.txt");

            String line;
            ArrayList BillArray = new ArrayList();

            //Read the first line of text
            line = sr.ReadLine(); 

            //Continue to read until you reach end of file
            while (line != null)
                //write the lie to console window
                //Read the next line
                line = sr.ReadLine();

            //close the file

            foreach (var item in BillArray)

        catch (Exception e)
            Console.WriteLine("Exception: " + e.Message);
            Console.WriteLine("Executing finally block.");