Homebrew installation failed
I removed the HomeBrew files by running the following command. After that, I ran the installation as mentioned in the above post. It all worked fine. I was able to install all the packages I need.
sudo rm -rf /usr/local/HomeBrew