Add a loop to read each line of the file, and read the entire line into one string

Hello, so I'm new to dealing with files, and I have a text file with data that I need the program to read each line and then output that string into the terminal. My file (Movedata.txt) looks like this (these aren't real names or contacts):

estimate move kind dist weight pianos orig_stairs dest_stair id name email
2016/4/19 2016/9/22 w 38 3588 2 n y 0 Ariana Carter b200833644@gmail.com
2016/5/9 2016/4/9 f 555 8639 2 y y 1 Milford Turner m2014341474@gmail.com
2016/5/1 2016/6/23 s 267 7554 1 n n 2 Ngan Clarke d170032616@gmail.com


So far my code looks like this:

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
33
34
35
36
37
38
39
40
41
42
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

int main() {


	ifstream inputFile; // File stream object
	string fileName = "Movedata";	// Hold the user entered file name
	string data;

	// Prompt the user to enter the data file name
	cout << "Welcome to Elsewhere Movers!\n";
	cout << "Please enter the name of the file to read from: ";
	cin >> fileName;

	// Open the input file
	inputFile.open(fileName.c_str());

	// If the file successfully opened, process it
	if (inputFile)
	{
		// Process data from file
		cout <<"Here is your data:\n";
		string arg1;
		string data;
		while (inputFile >>arg1 && getline(inputFile, data))
		{
			cout <<arg1 <<" ";
			cout <<data <<endl;
		}

	}
	else // the File could be found and opened
	{
		// Display an error message
		cout << "Error: file could not be opened. \n";
	}

	return 0;
}


When I enter in the name of the file, everything in the file comes up right away, but I don't think that's what I want. What I'm trying to do is create a loop so the program can read the file line by line, which I can't figure out how to do.
Topic archived. No new replies allowed.