Private Sub Button1_Click
    Dim a As FileChooser
    a.Initialize
    If SourceFileFolder <> "" Then a.InitialDirectory = SourceFileFolder
    a.Title = "Select huge file:"
    a.setExtensionFilter("Huge file", Array As String("*.*"))
    Dim fn As String = a.ShowOpen(Main.MainForm)
    If fn = "" Then Return
    SourceFileFolder = a.InitialDirectory
   
    Dim NeedleToSearch As String = "0Ua"
   
    Dim size As Long = File.Size("", fn)
    Dim rafInput As RandomAccessFile
    rafInput.Initialize(fn, "", True)
   
    Dim chunk_size As Long = Max(NeedleToSearch.Length * 2, Min(size / 100, 1000000))
    Dim buffer(chunk_size) As Byte
       
    Dim found As Boolean
    Do While rafInput.CurrentPosition < size
        Dim qtyToRead As Long =  Min(buffer.Length, size - rafInput.CurrentPosition)
        Dim positionToRead As Long = rafInput.CurrentPosition
        If qtyToRead > NeedleToSearch.Length Then
            positionToRead = Max(positionToRead - NeedleToSearch.Length, NeedleToSearch.Length)
        End If
       
        Dim count As Int = rafInput.ReadBytes(buffer, 0, qtyToRead, positionToRead)
        Dim b() As Byte
        If count = buffer.Length Then
            b = buffer
        Else
            Dim b(count) As Byte
            Bit.ArrayCopy(buffer, 0, b, 0, count)
        End If
        Dim text_chunk As String = BytesToString(b, 0, b.Length, "UTF-8")
        Log(text_chunk)
        If text_chunk.Contains(NeedleToSearch) Then
            found = True
            Exit
        End If
        Dim percent As Int = rafInput.CurrentPosition/size * 100
        Log(percent)
        If percent Mod 3 = 0 Then Sleep(1)
    Loop
    rafInput.Close
    xui.MsgboxAsync(found, "found")
End Sub