Oh, wait, I just spotted something! ``char`` cannot be used to store the value from ``fgetc``, its datatype is too small. Try replacing it with ``int``. What you are seeing is probably because ``current`` is too small to hold ``EOF``, its value wraps around and then the ``current == EOF`` check never succeeds.