Fix for leftover tmp file when doing two-stage transfers