Hey all, I was making a simple youtube downloader, but I can't figure out how to get the string to save to a file. I keep getting strange access violations, etc. 
SCAR Code:
program New;
var
c, i : integer;
s : string;
const
url = 'http://www.youtube.com/watch?v=RIQWsPJPHYY';
loc = 'C:\myfile.txt';
begin
i := GetSystemTime;
c := InitializeHTTPClient(true, true);
SetHTTPUserAgent(c, 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.20) Gecko/20081217 Firefox/2.0.0.20');
Status('Resolving link, standby...');
s := GetHTTPPage(c, url);
s := 'http://www.youtube.com/get_video?video_id='+Between('video_id=','&',s)+'&t='+Between('&t=','&',s)+'&el=detailpage&ps';
Status('Resolved link, downloading...');
s := GetHTTPPage(c, s);
writeln(s);
FreeHTTPClient(c);
Status('Download complete, copying...');
c := OpenFile(loc, false);
WriteFileString(c, s);
i := GetSystemTime - i;
//CloseFile(c);
s := 'Saved succesfully to '+loc+', took '+IntToStr(i)+'ms, ';
i := FileSize(c);
s := s + 'downloaded '+IntToStr(i) + 'bytes.';
Writeln(s);
end.