Copies a file programmatically