SD Card initialize problem
I believe that the SD card shield is already using pins 12 and 13 for the SPI interface.  You won't be able to use both the distance sensor and the SD card on those pins (and even just connecting the two shields as-is could cause problems).