Unable to create a file on SD card using arduino UNO.

I want to merge two different codes that is inserted below. When I merge them, the value obtained by analog input shows up on the serial monitor but does not get stored onto a file in the SD card. It would be great if you guys could help me out.

  1. Code to create a new file on SD card
#include<SD.h>
#include<SPI.h>
File myFile;
int pinCS = 4;
void setup()
{
Serial.begin(19200);
pinMode(pinCS, OUTPUT);

if(SD.begin())
{
Serial.println("The SD card is ready");
}
else
{
Serial.println("The card initialization failed");
return;
}
}

void loop()
{
int sensorValue = analogRead(A0);
Serial.println(sensorValue);

myFile = SD.open("example.txt", FILE_WRITE);
delay(100);
if(myFile)
{
myFile.println(sensorValue);
myFile.close();
}
else
{
Serial.println("Error opening example.txt");
}
}
  1. Code I want to merge with the above one.
//this code will enable all three Arduino timer interrupts.
//timer will interrupt at 1Hz

void setup()
{
Serial.begin(19200);
Serial.flush();

cli();

TCCR1A = 0;
TCCR1B = 0;
TCNT1 = 0;
OCR1A = 61;
TCCR1B |= (1 << WGM12);
TCCR1B |= (1 << CS12) | (1 << CS10);
TIMSK1 |= (1 << OCIE1A);

sei();

}

ISR(TIMER1_COMPA_vect)

{
Serial.println(analogRead(A0));
}

void loop
{

}