file copying rewritten