Fixed broken loop meant to close handles after copy