using loopWithLog in the writer monad