Data Isn't Being Written to SD Card

I've devised a basic setup running an SD card shield to retrieve a number stored in a text file on the SD card, and use it as the rate at which a statement will be written to the SD card in a .csv file.

However, let alone writing the statement to the .csv file, even the task to retrieve the number from the text file fails. Both the processes don't work, and the else flag statements are triggered.

Here's the code:-

#include <SD.h>

//Set by default for the SD card library
//MOSI = pin 11
//MISO = pin 12
//SCLK = pIN 13
//We always need to set the CS pin
const int CS_PIN  =10;
const int POW_PIN =8;

//Default rate of 5 seconds
int refresh_rate = 5000;

void setup()
{
  Serial.begin(9600);
  Serial.println("Initializing Card");
  //CS pin is an output
  pinMode(CS_PIN, OUTPUT);
 
  //Card will draw power from pin 8, so set it high
  pinMode(POW_PIN, OUTPUT); 
  digitalWrite(POW_PIN, HIGH);
 
  if (!SD.begin(CS_PIN))
  {
    Serial.println("Card Failure");
    return;
  }
  Serial.println("Card Ready");
 
  //Read the configuration information (speed.txt)
  File commandFile = SD.open("ID.txt");
  if (commandFile)
  {
     Serial.println("Reading Command File");
  
     while(commandFile.available())
     {
       refresh_rate = commandFile.parseInt();
     }
     Serial.print("Refresh Rate = ");
     Serial.print(refresh_rate);
     Serial.println("ms");
     commandFile.close(); // close the file when finished
  }  
  else
  {
    Serial.println("Could not read command file.");
    return;
  } 
}
void loop()
{
 File datafile=SD.open("log.csv");
 if(datafile)
 {
  datafile.println("Adeel is cool");
  datafile.close();
  Serial.println("Write successful!");
 }
 else
 Serial.println("You're a failure at life.");
 delay(refresh_rate);
}

While the SD card initialization process is successful, neither the reading nor writing processes work.
What seems to be the problem? I've doublechecked my wirings and the code as well, and yet, nothing suffices.

//Card will draw power from pin 8, so set it high
pinMode(POW_PIN, OUTPUT);
digitalWrite(POW_PIN, HIGH);

I would be surprised if this works. SD cards do need some pulses of high current for some actions. Nothing like a WiFi transmitter but they still need adequate power.

Wire it to proper power and try again. Maybe you can use this pin to control a MOSFET to power the SD card in the future.

Short answer. You need to keep the power of pulses low in order to achieve the task.
Regards.