/*
    第2種情報処理技術者試験    平成6年度・秋期・午後 問11(設問2)
                                BohYoh Shibata PREPARATION
*/

#include <stdio.h >

#define WIDTH 60

main()
{
    FILE *fp;
    int ch, pos = 0;
    int bch = '\0';

    fp = fopen("txt_file", "r");
    while ((ch = fgetc(fp)) != EOF) {
        if (ch != ' ' || bch != ' ') {
            if ((pos >= WIDTH) && (ch != '\n')) {
                putchar('\n');
                pos = 0;
            }
            putchar(ch);
            pos = (ch == '\n') ? 0 : pos + 1;
        }
        bch = ch;
    }
    fclose(fp);
}