CB-2333: Probably should be re-factored as a do..while, but need to handle when there is no EOL char in buffer