Thank you so much @ballscrewbo, for your reply. It is working well now!! :); Since MKR1000 did not give me any LED indication when I connected LIPO battery I thought it is not working. Later I came to know, it has been designed in that manner to better optimize battery power consumption.
But I have baffled with a strange problem now, it is behaving differently when it connected to a computer vs on a 3.7V, 1400mAh LIPO battery. problem is quite similar to the one mentioned here, on Arduino Uno. But here they suspect drop in voltage as the villain. But my multimeter gives me 3.7V almost always.
I am attaching a small snippet of the code for the reference here. Could you shed some light on this?