Fixed how read eof is treated. Used some C defines