Move writes before io.EOF check