My R version is 3.5.1, it does not seem to work for me. I got the following error whiles running the fix code
Error in readLines(f) :
(converted from warning) incomplete final line found on 'C:\Users\Ismaela.Abubakar\Documents.Rprofile'
Hurray!!!, it is fixed now
Many thanks