When I close the lid of my laptop, the Wifi should not disconnect automatically

Solution 1:

At first I didn't understand your question but then surmised if you are closing your lid and want WiFi to stay on that must mean you have your Laptop docked or have an HDMI monitor attached and the system is suspending the Wifi.

You already edited logind.conf once and need to again. Set the line:

HandleLidSwitchDocked=ignore

Then save the file and reboot. Hopefully this solves the problem. If so mark this as solution by clicking check mark, if not post a comment.