You don't mention your operating system, but its console I/O is probably limited to 4096 bytes (see for example this). And with the newline and null terminator, you are seeing 4094 bytes.
There is no machine-independent way to change this limit, as far as I can see. And in any case, it just feels wrong to use console I/O on large amounts of data. I suggest a re-design, perhaps using the suggestion in @VaibhavDS's answer.
By the way, what happpens if you call getchar
after exiting the loop? I expect that the input data has been lost, but it might still be there.
Edited to add: You might find something useful at this answer.