Seems to me that you're not only making assumptions but also occasional omissions. There is a constant stream of fresh energy coming into the system in the form of heat. Therefore it is not a perpetual motion machine as you ASSUME.