Implemented a basic message reading loop