Hey Gerry,
Yes, the chipSelect is for the SD card.
The variable SS (Slave Select) is built into the SPI library and each Arduino has its own standard SS pin. In the MEGA's instance, the standard pin that the SPI library tries to use is pin 53. I am not using that pin, but since I am using the SPI library, I have to declare that pin as an OUTPUT.
About 4 lines down from my declaration for SS, you will see my SD.begin statement. In that statement, when I put (chipSelect) in the begin call, I am telling the SPI library that the slave select for the SD card is Pin 4.
dataFile.close() and dataFile.flush() do the same thing in regards to telling the SD card to save the data. dataFile.close() goes ahead and closes the file as well. This project is planned to be in operation with no human interaction for about 2 years, I am only saving data every 5 minutes. I don't want to keep the file open if the box is just going to sit there; there is a lot of time for a power outage or something else to corrupt the data file. Plus, my experience with this project leans me towards keeping the SD card and Ethernet operations completely separate from one another. Completely shut one down before using the other.
Thanks for the thoughts.
Tim