I'm writing a program that will keep track of every Anime/Manga I watch/read(I'm an avid fan). I'm trying to make a database in order to keep track of all of the titles of the Anime/Manga. My problem is that when i try to add a new title to the existing list, it overwrites the entries that are already there. Here is the code for my add function.

int Add(void)

    cout << "What is the title of the Anime/Manga that you wish to add?" << endl;
    cout << "::>";
    cin >> Title;

    outfile << Title << endl;


As I said it overwrites what was already in the file. Here is the function that reads the content of the file in case that might help.

int List(void)
    int count = 0;


    //Check for errors
        cerr << "Could not open Database file.";

        infile >> Title;
        cout << Title << endl;

    //Display number of entries
    cout << count << " entries found." << endl;


I have infile and outfile declared globally if that matters. Title is also global.

Open the file in the mode that appends new data on the end instead of overwriting the existing data.

outfile.open("database.txt", ios::app);

This question has already been answered. Start a new discussion instead.