annoying output

http://pastebin.com/rQ7M0JEm

Hello everyone I am currently just trying to figure out why when I input write instead of read in the program it outputs the same string twice. I mean the code works its just really annoying me and I can't for the life in me figure out why it bis behaving in such a manner.

any tips would be appreciated

cout<< "what would you like to do today? read or write a file: "; this line outputs twice when I enter write
you have a newline left in the input stream.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
void pencil::write()// this will create a new file and allow you to input numbers into it
{
	string input;
	ofstream outputFile;
	float num1 = 0;

	cout << "what is the name of the file with extention you want to create?: ";
	getline(cin, input);

	outputFile.open(input.c_str());

	while (num1 != -1)
	{
		cout << "Enter the number: (enter -1 to end):  ";
		cin >> num1;
		cin.ignore();//-------------------------------------------add this

		if (num1 != -1)
			outputFile << num1 << endl;
	}
	outputFile.close();
}
Thank you I appreciate it
Topic archived. No new replies allowed.