make logger synchronous, fixes #12
Change reading to loop until enough bytes are read