Movement related to temperature

It is a bad idea to open and close the SD file every time you pass through loop().

Open it once in setup, then close it when you are finished logging. If the power fails before you have a chance to close the file, you will lose at most the last couple of output records.