When I was testing the input, I entered values and appended them to the file. You mean ..should i create an array of objects for this program to work ? Is there no other way I can do it ?

Well if you have multiple records in one file and want them all you either need multiple objects or data members that are arrays. If you want each object to have just one set of values you will have to go one way. If you want the one object to hold all of the data then you will have to go another way. Let me know how you want to implement it and I can help you out.