The program doesn't need multiple loops statements or any else statements.
This seems like a straight-forward way to solve the problem:
#include <stdio.h>
int main(void) {
int single_byte;
int last_char;
for(last_char = 0; (single_byte = getchar()) != EOF; last_char = single_byte)
{
if(last_char != ' ' || single_byte != ' ')
putchar(single_byte);
}
}