Implemented a loop, so that multiple messages can be sent/received.