Refactor the stream reader slightly for better readability.