I am unable to get a new line in a text file

I am writing a linked list in C++, I cant seem to get a new line in my text file, everything I enter seems to wind up in one line, please help, here is my code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main()
{

ofstream theFile("linked_list.txt");

cout << "Please enter the Type of component, Manufacturer, Number in stock and Cost in pence" << endl;
cout << "Press CTRL + Z to end file" << endl;

string Type;
string man;
int stock;
int cost;

theFile << "Type of component" << ": " << "Manufacturer" << ": " << "Number in stock" << ": " << "Cost in Pence" << ". " << endl;

while(cin >> Type >> man >> stock >> cost)
{
theFile << Type << ": " << man << ": " << stock << ": " << cost << ". " << endl;


}

return 0;
}
endl is outputting a newline to the file. The problem doesn't seem to be in this code, but may be something to do with how you are viewing the contents of the file.
Topic archived. No new replies allowed.