calling end() also waits for all write()'s to finish before closing