Thank you for the information,
From your history, it is likely to be due to fungal infection as it is responding to otc anti fungal ointment.
It can produce black discoloration of the nail.
Sometimes other conditions like low blood supply, melanoma can cause black coloration.
But response to treatment, normal temperature etc. suggest fungal infection more likely.
It can stay for months.
I would suggest to get an examination by your primary doctor first.
He can then refer you if he thinks necessary.
Often long treatment is required.
Local anti fungal cream is not much effective.
Still you can try otc creams.
Oral antifungal drugs like fluconazole, griseofulvin
, terbinafine, itraconazole are usually required.
It should be taken regularly, often 2-3 months.
Laser treatment can help to clear the fungus.
I hope this information helps.
I will be happy to assist, if you need any clarification.
Please feel free for any follow up query.