Here's the deal, then.
Open a file for output.
Set up a while loop. Inside the loop, ask the user to enter two numbers. Validate the input and, if correct, write them to the file. Exit the loop on some input condition, such as an empty line.
Close the file.
The particular functions you use for file I/O and for user input will depend on whether or not you are using C or C++. You don't say, and you don't give any indication of your level of expertise.
I would strongly recommend you read this