added finish condition and commeted out buffer flush code in client