In the "else" part where the downloading is "finished" add a condition like this (code from visual example):
FFile.Write(Buf, i);
end else if FDLDone + i >= FDLSize then begin // done whole file
// file download ended
FYI... I tried this technique in my original routine and it's working great in Windows now!