fix append on $tmpfile