Try this
Sub test()
    Dim fn As String, txt As String, e, x, temp As String
    fn = Application.GetOpenFilename("TextFile,*.txt")
    If fn = "False" Then Exit Sub
    txt = CreateObject("Scripting.FileSystemObject").OpenTextFile(fn).ReadAll
    x = Split(txt, "outer loop" & vbCrLf): txt = ""
    With CreateObject("VBScript.RegExp")
        .Global = True: .IgnoreCase = True
        For Each e In x
            If e Like "*end loop*" Then
                temp = Split(e, vbCrLf & "end loop")(0)
                .Pattern = "(\d)(?= ) "
                temp = .Replace(temp, "$1,")
                .Pattern = "[a-z]+ "
                temp = .Replace(temp, "")
                txt = txt & vbCrLf & temp
            End If
        Next
    End With
    Open Replace(fn, ".txt", "_revised.txt") For Output As #1
        Print #1, Mid$(txt, 3)
    Close #1
End Sub