fixed rename logic. In windows you can not rename open file.