I would like to know how to replace all spaces in different sentences in a txt file with ellipses.

For example:

* Original sentence: `Hi my name is Joseph.`
* Modified sentence: `Hi... my... name... is... Joseph...`

The text structure is the following:

* sentence 1.
* sentence 2.
* sentence 3.
* sentence 4.
* .......

(Each sentence ends with a dot). I have made a code but it only works from a manually typed sentence:

```
#include<stdio.h>

int main() {  
    char ch = getchar();

    while (ch != EOF) {
        if (ch != '\n' && ch != ' ') {
            putchar(ch);
            ch = getchar();    
        }
        else {   
            printf("... ");
            while (ch == '\n' || ch == ' ') {
                ch = getchar();
            }  
        }  
    }
    putchar('\n');
    return 0;
}

```

Does anyone know how to modify this code to read the sentences from the file and make the changes with the dots?