Spot the bug in the byte-copy loop

from C file I/O
C23 (GCC 13.3.0) intermediate 4 min 1 issue to find

Find the portability bug in this byte-copy loop.

C
#include <stdio.h>

int copy_bytes(FILE *input, FILE *output) {
    char byte;
    while ((byte = fgetc(input)) != EOF) {
        if (fputc(byte, output) == EOF) return -1;
    }
    return ferror(input) ? -1 : 0;
}
Open in playground
Report an error