What you see in the Resource usage view is not tasks - it is assignments. So, you'd need to loop through each
assignment (not task) and write the data. I am not a coder, so my suggestion is to post your question (including what release of project you are working with) to the Forum for project customization:
http://social.technet.microsoft.com/...ct2010custprog
If you do post there, if you could post back to this thread with the thread url from the TechNet forum - that would be very helpful.