Welcome to CS 106B/X Random Writer ('N-Grams')!
This program generates random text based on a document.
Give me an input file and an 'N' value for groups
of words, and I'll create random text for you.

Input file name? badfile
Unable to open that file.  Try again.
Input file name? notfound.txt
Unable to open that file.  Try again.
Input file name? hamlet.txt
Value of N? 0
N must be 2 or greater.
Value of N? -4
N must be 2 or greater.
Value of N? aoeu
Illegal integer format. Try again.
Value of N? 4

# of random words to generate (0 to quit)? xyz
Illegal integer format. Try again.
# of random words to generate (0 to quit)? 2
Must be at least 4 words.

# of random words to generate (0 to quit)? 40
... beyond ourselves in our opinions As it is common for the younger sort To lack discretion. Come, go we to the King. They have letters for him. Ere we were two days old at sea, a pirate of very warlike ...

# of random words to generate (0 to quit)? 20
... no cataplasm so rare, Collected from all simples that have virtue Under the moon, can save the thing from death ...

# of random words to generate (0 to quit)? 0
Exiting.
