Reading from file problem

Having trouble reading from a file. I have a text file that reads:
1
2
3
4
0000
0000
0000
1111


When I output the following to the console, the program reaches the end of file on the third row and doesn't print out the

 
1111


Here is the full source 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
33
34
35
36
37
38
39
  #include <iostream>
#include <fstream>
#include <cstdlib>

using std::cout;
using std::endl;
using std::ifstream;

int main()
{
	const int SIZE = 50;
	ifstream fin;       
	fin.open("Map.txt");
	

	if(!fin.is_open())
	{
		exit(EXIT_FAILURE);
	}

	char word[SIZE];
	fin >> word;

     int num;	
	
	while(fin.good())
	 { 
	    cout << word << " " <<endl;
	    fin >> word;
			
	}


	
	fin.close();
	
	system("Pause");
return 0;
}


What could be the problem. I think its because I am using a char array to read the input. But that wouldn't make sense considering char to int is similar. Need a second opinion thanks.
Nothing major, just the ordering of your 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
33
#include <iostream>
#include <fstream>
#include <cstdlib>

using std::cout;
using std::endl;
using std::ifstream;

int main()
{
	const int SIZE = 50;
	ifstream fin;       
	fin.open("Map.txt");
	

	if(!fin.is_open())
	{
		exit(EXIT_FAILURE);
	}

	char word[SIZE];
	
	while(fin.good())
	{ 
		fin >> word;
		cout << word << " " <<endl;	
	}

	fin.close();
	
	system("Pause");
	return 0;
}
Wow, thanks Smac89.

I was scratching my head for hours trying to figure out what I was missing.

Thanks again
Topic archived. No new replies allowed.