implement copyIntoFile