I think the first port of call with this would be to check what your browser is telling you when you open your html file.
In the browser open the file you create and hit F12. This will open the "developer" window of the browser (should work in Edge and Chrome). Head to the console and any errors in the html will present here.
Next lets look at your code.
You seem to spend a bit of time getting the text file converted to csv. To troubleshoot, try converting this text file into csv another way. Try Excel if you can or your preferred spreadsheet program. Once you have a csv setup, test that this can be loaded in QGIS or another program (to make sure there no issues there).
If that all works, have a look at this simple working Heatmap script, see if you can gleam anything out of it.
import pandas as pd
from folium import plugins
from folium.plugins import HeatMap
import folium
import webbrowser
data = r'PATH TO YOUR CSV'
df = pd.read_csv(data, skiprows = 0)
print (df) ## Check your data is loading correctly
heat_df = df[['Y','X']] ## or df[['lat','long']] from your case
m = folium.Map(location = [0,0], zoom_start = 6, max_zoom = 10) ## Choose a location closer to home for you - you can add the "fancy" mean lat long once you have it working
HeatMap(heat_df,radius = 20, min_opacity = 0.5, max_val = 10, gradient={.25:'blue', .5: 'lime', .75:'yellow', 1:'red'}).add_to(m)
## breaking this down, the data is the heat_df, we set the HM radius to 20 units, we control the opacity and set the colour of the heatmap from green to red
m.save (r'c:\temp\example.html')
webbrowser.open(r'c:\temp\example.html')
Once you have a working example, you can tweak the code to be fancier and less "hands-on" with the data processing in the beginning.