Use unsigned char everywhere, implemented an EOL detection function