Are we talking about even roughly the same concept of functional purity [1]? Nothing is stopping a pure function from representing EOF as -1.
Implementing IO in a "pure" way, is however another discussion.
[1]: https://en.wikipedia.org/wiki/Pure_function