Fixing DistCopy - flush stream before moving tmp file

@raronson @charleso 
You could use `ResultT.when` and `ResultT.unless` if you wanted /uptoyou