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

using namespace std;

int main() 
{
  vector<string> vect(1);
  ifstream inFile;
  string consoleStr = "Enter Filename>>  ";
  string fileName;
  string word = "";
  char c;


  cout << "Welcome! Enter filenames to parse or 'quit' to exit.\n" << endl;

  cout << consoleStr;
  cin >> fileName;
  while(fileName.compare("quit") != 0) {
    cout << "Opening file:\n\n";
    inFile.open(fileName.c_str());
    
    if (inFile.is_open()) {
      while(!inFile.eof()) { // Not end of file!
	c = inFile.get();
	
	// ASCII Codes for 'A-Z','a-z':
	if ((c >= 65 && c <=  90) || (c >= 97 && c <= 122)) {
	  word.append(1,c); // Add character to word
	}
	else {
	  if (!word.empty()) {
	    vect.push_back(word); // Add word to vector
	  }
	  word = ""; // clear word
	}
      }

      vect.push_back(word);
      word = "";
    }
    else {
      cout << "Could not open file!\n";
    }

    inFile.close();
    inFile.clear();

    vector<string>::iterator i;
    for (i = vect.begin(); i != vect.end(); i++) {
      cout << *(i) << "\n";
    }
    vect.clear();

    cout << consoleStr;
    cin >> fileName;
  }

  return 0;
}
