#include <iostream.h>
#include <fstream.h>

void writeToFile()
{
    ofstream ofile("myfile.txt");
    if (ofile == 0)
    {
        cerr << "Can't open file \"myfile.txt\" for writing\n";
        exit(1);
    }
    
    float val;
    while (cin >> val)
    {
        if (val == -2001) // indicates end of input
        {
            break;
        }
        
        ofile << val << endl;
        cout << "Wrote value " << val << endl;
    }
}

