Health Savings Account

Please let me know know if I'm missing something regarding the following scenario. Is it possible to do this in the same tax year (if over age 59 1/2):

Withdraw say $4K from traditional IRA and pay taxes on the withdraw.

Put $4K into an HSA and as a result lower taxable income by $4K.

Take $4K out of the HSA and use the money for medical expenses thus avoiding any tax on the withdraw.

This feels like money laundering and gaming the system, but hey if it's legal.....