You can use code like this in your 'input loop' for program #2.
  /* skip over any leading white space that may be in the input*/
  cin >> ws ;
  while (cin.peek() != EOF) /* check for end of file before reading each datum.*/
  {
      (here read in 8 contiguous digits into an array )
      ( here insert the array into a queue, 
         or do whatever you want to do with it now. )
      /* the line below skips over all white space that comes after the item
	 that was just read (the 8 digits).  The postcondition is: The 'file
	 pointer' will be positioned to read the next 'black space' character
	 - if one exists.  If not, the file pointer will be positioned at the
	 end of the file. */
      cin >> ws ; 
  }