Fixes error handling in read buffer