The bug is that I colse file after returning p.
When I chang the position ('fclose (out) ') and put it before returning p . It work normally.
Thank you for everything you do for me.

I bother with you for a period time.
Thank you Tony and Bob.
Thank you very much!