Deleting extra files and writing document to correct path