Implemented a (hopefully) functional read_command_stream function