switch to BufWriter in test