Arduino SDFat Libray overwrites last value
You just need to open the file in APPEND mode:

SpeedCache.open("/Speed_Cache.txt",O_CREAT | O_RDWR | O_APPEND);



  O_APPEND
  
  The  file  is  opened  in append mode.  Before each write, the file offset is positioned at the end of  the  file,  as  if  with               lseek.


You should also pass your file around by reference so it doesn't keep creating new copies of the internal structure:

bool SDClass::SetLine(SdFile &amp;Cache,int target, int reference)