SD and TimerOne periodic inaccuracies

I’m trying to get familiarized with Arduino by writing (yet another) data logger.
My first experiment was to use timer one to launch a function which opens a file, writes the current value of millis() and then closes it. Something like this:

#include <TimerOne.h>
#include <SD.h>

File myFile;

void setup()
{
   ... 
  Timer1.initialize();
  Timer1.attachInterrupt(write_to_file, SAMPLING_PERIOD);
  ...
}

void write_to_file(void){
  myFile = SD.open("experiment.xls", FILE_WRITE);
  myFile.println(micros());
  myFile.close();
}

Then I used OOCalc to calculate the difference between every two consecutive saved values (and therefore obtaining the actual “sampling rate”, so to speak) . Some small inaccuracies appeared (as expected), but I’m surprised that:
a) The inaccuracies appear periodically.
b) If timerOne is set to a period of say 1 second, the saved values of micros() are always less than 1 second apart.
c) If the sampling rate is more or less high, values of micros are not always increasing (sometimes I found say 10000 before 9999) .
Here’s an example for SAMPLING_RATE=10000000 (1s)

Any idea why this happens?
Thank you!

Using Arduino UNO, with a fat16 SD Card

Do you know if the timer library calls your ISR with the interrupts disabled? That would stop the clock interrupts that maintain the millis() and micros() counters while Timer 1 would still be counting. Try enabling interrupts at the top of your ISR.

Try enabling interrupts at the top of your ISR.

Interrupt service routines are supposed to be very, very fast.

Opening a file on an SD card is not fast. Writing to a file on an SD card is not fast.

In the ISR, you really should be setting a flag that indicates that a write is required, recording the value for micros(), and nothing else.

In loop, check for the flag being set, and do the write there.

Open the file once, write to it for a while, and then close it. Opening every time you write requires finding the insertion point again.