A text file is given as input.
You have to arrange the strings by reordering them in the following manner:
For every
word that ends with a letter,
the next word should start with the same letter.
The words that do not match must be written at the end of the file.