Problem with temp sensor?

I am totally new to programming and Arduino, so I bought the official starter kit. I've been following the projects in the book, but now that I'm on the third project, measuring heat, I can't get it to work. I have copied the code from the book exactly as far as I can see, and I get a good base reading. But when I touch the sensor the reading goes up to 40-60 C and then does not go down. It just stays there forever. The only way to make it go down is to close and reopen the monitor screen, then it directly goes down to 22 C again.

Is this a problem with the code (which is directly from the book), with the hardware or the software? What should I do? I have been trying everything I can come up with for a couple of hours...

Thankful for any suggestions.

Update: I removed the part of the code that made the LEDs go on/off and now the temperature reading seems a lot more probable. But it still takes waaaay too much time to go down again from 25 to 22 degrees...

Btw, sorry if this is the wrong part of the forum, since I didn't know what the problem was I didn't know where to post...