//Reads numbers from file inFile.txt and
//Prints numbers to file outFile.txt
#include <fstream>
#include <iostream>
using std::ifstream; //input file stream
using std::ofstream; //output file stream
using std::endl;		//end of line character
using std::cout;		//screen output stream

int main(){
	ifstream in;						//input stream in declared
	in.open("inFile.txt");	//in connected to file inFile.txt
	//preceding two lines can be replaced with 
	//ifstream in.open("inFile.txt");
	ofstream out;						//output stream out declared
	out.open("outFile.txt");//out connected to file outFile.txt
	//preceding two lines can be replaced with 
	//ofstream in.open("outFile.txt");

	double number;
	bool more = true;
	while(more){ 
	   in>> number; 
	   if(in.fail()){//handles bad input and eof
		   more = false;
		   if(in.eof())
			   cout<<"\nEnd of data." <<endl;
		   else
			   cout<<"\nBad input data." << endl;
	   }
	   else{
		   cout<<"\nRead from file inFile.txt and wrote to file outFile.txt " << number; 
		   out << number<<' ';
	   }

   }
	in.close();
	out.close();

	return 0;
}