Hi Sonu,
If the code is working without the power cycle, it seems that it is a timing or power issue. You could try checking your power supply in order to discard some peaks that cause abnormal SD card operation, or trying adding a delay before the SD card initialization, in order to ensure that the card is already self-initialized for a correct communication.
Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------