Write Serial Monitor to SD Card

I have a simple program with a single digital input (high/low) and a function that keeps track of how many “cycles” the input has gone through (the input alternates between high and low). The serial monitor shows “Cycle: XX”.

I want to write this output (“Cycle: XX”) to a text file stored on the Micro-SD card in my Arduino Yun board.

What is the most efficient way to automate this process?

Any help would be great!!

Check out this tutorial http://arduino.cc/en/Tutorial/YunDatalogger
and this one to the Bridge Library