Removing Extra Spaces

  1. Download a text file which contains a few sentences.
  2. In this file, there may be multiple spaces between words.
  3. Write a program to read the contents of this file, replacing contiguous spaces with a single one, and print out the sentence.
  4. The result may look like:
    
    Makes a copy of the target sequence (the subject) with all matches
    of the regular expression rgx (the pattern) replaced by fmt
    (the replacement). The target sequence is either s or the character
    sequence between first and last, depending on the version
    used.
    
    The resulting sequence is returned as a string object on versions
    1, 2, 3 and 4. Versions 5 and 6 take an output iterator as first
    argument, which is used to store the resulting sequence.
    
    An optional parameter, flags, allows to specify options on how to
    match and format the expression.