Tempstar furnace, pilot light turns on then off in 1 second

I have a Tempstar natural gas furnace. It has electric element for ignition of the pilot.
It was working fine all December. Now, it does not work as follows: the draft fan starts and runs correctly, then a good looking pilot light comes up. In less than one second, the pilot light turns off and the main burner does not ignite.
I spent a while troubleshooting this issue. I cleaned the pilot sensor with light emery cloth. It did not seem to help. It seems that if I remove two screws holding the pilot light in place and pull it out of the furnace, it does ignite and hold, and if I insert it back into the furnace, the main gas ignites.
I put it back in and everything seems to work. I turn the furnace off, then on, and the pilot stays and the burner lights. Then I went to sleep and again woke up in a cold house.
Overall this behavior seems to be somehow "erratic". As in, things seem to work, then after a while the pilot starts going away again.
Would there be some coherent explanation of this behavior.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
Add image file

HomeOwnersHub.com is a website for homeowners and building and maintenance pros. It is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.