Hi @Marta ,
You can refer to the following code.
Dim f1() As String = File.ReadAllLines("C:\Users\Administrator\Desktop\1.txt")
Dim f2() As String = File.ReadAllLines("C:\Users\Administrator\Desktop\2.txt")
Using Sw As StreamWriter = New StreamWriter("C:\Users\Administrator\Desktop\3.txt", True)
Dim a As Integer = 0
For i = 0 To f1.Length - 1
If f1(i) Is "" OrElse i = f1.Length - 1 Then
For j = a To i
If f2(j) IsNot "" Then
Sw.WriteLine(f2(j))
End If
Next
a = i
Else
Sw.WriteLine(f1(i))
End If
Next
End Using
Best Regards.
Jiachen Li
----------
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.