[SOLVED] Writing limitations to SD card after ~250 writings?

	if(ch == 0)

How are you sending data to the Arduino? Sending a binary 0 seems like a strange thing to do.

startlogging() is incorrectly named, since it does not start the logging. The else clause is misplaced, now, since the file is not created in startlogging().