write loop