Fix file saving on second try