/******************************************************************
* This program reads any number of lines of text, replacing each  *
* newline with double newlines, and any number of spaces with a   *
* single space.                                                   *
* Skeleton written by Roger Hartley, completed by _____________   *
******************************************************************/

#include <stdio.h>

int main() {
  int ch, last = 0;

  ch = getchar(); /* read a character from the input*/
  while (ch != -1) {
     /* read characters for the input until there are no more */
     if (ch == '\n') { /* character read is a newline */
       putchar('\n');
       putchar('\n'); /* then write two newlines to the output*/
     }
     else if (ch != ' ') { /* it's not a space */
       if (last == ' ') /* last character was a space */
	 putchar(last);
       putchar(ch);
     }

     last = ch; /* remember the last character */
     ch = getchar(); /* read another character from the input*/
  }

  return 0;
}

