/// <summary>
        /// Does the actual downloading
        /// </summary>
        /// <param name="o">InternalDownloadParams containing relevant data.</param>
        internal static void InternalDownload(object o)
        {
            var operation    = (FileDownloadOperation)o;
            var streamReader = new StreamReader(operation.Stream, Encoding.UTF8, true);

            var progressEventArgs = new ProgressEventArgs()
            {
                TotalBytes = operation.FileInfo.TotalBytes
            };
            long bytesRead           = 0;
            long notifyProgressEvery = 128;

            using (StreamWriter streamWriter = new StreamWriter(operation.TargetPath, false))
            {
                try
                {
                    string line;
                    while (!streamReader.EndOfStream)
                    {
                        line       = streamReader.ReadLine();
                        bytesRead += line.Length;
                        streamWriter.WriteLine(line);
                        if (bytesRead >= notifyProgressEvery)
                        {
                            notifyProgressEvery += 128;
                            progressEventArgs.DownloadedBytes = bytesRead;
                            operation.RaiseProgress(progressEventArgs);
                        }
                    }
                    //char[] buffer = null; not working! file has nulls
                    //while (!streamReader.EndOfStream)
                    //{
                    //    int size = streamReader.Peek();
                    //    if (size>=4)
                    //        size=4;

                    //    buffer = new char[size];
                    //    int read = streamReader.Read(buffer, 0, size);

                    //    streamWriter.Write(buffer);

                    //    bytesRead += read;
                    //    if (bytesRead % notifyProgressEvery == 0)
                    //    {
                    //        // Report progress
                    //        progressEventArgs.DownloadedBytes = bytesRead;
                    //        operation.RaiseProgress(progressEventArgs);
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                    operation.RaiseEnded(new EndedEventArgs()
                    {
                        Success = false, Exception = ex
                    });
                }

                // Update the file info with physical file info
                System.IO.FileInfo f = new System.IO.FileInfo(operation.TargetPath);
                operation.FileInfo.TotalBytes  = f.Length;
                operation.FileInfo.FileCreated = f.CreationTime;

                // Notify that we have succeeded
                operation.RaiseEnded(new EndedEventArgs()
                {
                    Success = true
                });
            }
        }