Fix huge memory consumption bug in downfile()