Reading Signal through analog input A5, SD card is not being written while A5=0V

On UNO and similar Arduinos, the I2C pins used for the DS1307 are pins A4 and A5. But you are using A5 as the square wave input as well.
Move the square wave pin to something that's not already being used by the RTC/uSD etc.

Pete