Update receive script to handle errors when reading message