Add a helper to copy a file
Update the way of closing resources