the_post_thumbnail
prints data to the screen immediately. It does not return a string that you can concatenate into your $out
variable.
Use get_the_post_thumbnail
instead.
Make sure you get the arguments right. They are different from the arguments for the_post_thumbnail
. Should be something like:
get_the_post_thumbnail(get_the_ID(),'thumbnail');