

#include <stdio.h>

/* This program takes a file and causes a single newline to disappear
unless it comes at the end of a line that begins with a period
or just before a line that begins with a period.
*/

main(argc, argv)
int argc;
char *argv[];
{
	int charactercount, dotbeginning, doublenewline, verbatim;
	int c, prevchar, beforeprevchar, printed;
	doublenewline = 0;
	prevchar = 0;
	beforeprevchar = 0;
	dotbeginning =0;
	charactercount =0;
	verbatim = 0;
	while ((c = getchar()) != EOF)
	{
		if (c == '-') {
			/* save it */
			printed = 0; /* character not printed */
		} else if ((c == '\n') && (prevchar == '-')) {
			/* save it, we are going to condense the two of them.*/
			printed = 0; /* character not printed */
		} else if ((c != '\n') && (prevchar == '-')) {
			/* hyphenated word */
			putchar('-');
			putchar(c);
			printed = 1;
			/* character printed */
		} else if ( (c == ' ') && (printed == 1) && (prevchar == '\n')) {
			/* newline was in fact printed */
			printed = 0; /* don't want that blank */
		} else {
			putchar(c);
			printed = 1;
		}
		prevchar = c;
	}
}
