#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>

int main(void)
{
    int fd = open("TEST.TXT", O_RDONLY);
    if (fd < 0) {
        puts("cat: cannot open TEST.TXT");
        puts("Press any key to exit...");
        (void)getchar();
        return 1;
    }

    puts("--- TEST.TXT ---");

    char buf[64];
    int n;
    while ((n = read(fd, buf, sizeof(buf))) > 0) {
        for (int i = 0; i < n; i++) {
            putchar((unsigned char)buf[i]);
        }
    }

    close(fd);

    puts("");
    puts("--- end of file. Press any key to exit. ---");
    (void)getchar();
    return 0;
}
