Fix checking extension of tmp name, now checks tmp file that is renamed to original name