Arduino Xbee Wireless SD shield

For some reason that data that is being transfered does not show up on the .txt file. I know the Receiver is working because the data does appear on serial monitor. Here are the essential lines in the receiver code.

#include <SD.h>
#include <SdFat.h>
#include <SdFatUtil.h>
#include <ctype.h>

void setup()
{
Serial.begin(9600);
pinMode(10,OUTPUT);
}

voidloop()
{File dataFile=SD.open("datalog.txt",FILE_WRITE);
if (datafile){
dataFile.write(Serial.read());
dataFile.close();
}
}
It is a micro sd card I am that i am trying to record data to. I also have the switch on the shield to "MICRO" when I run it.
Any ideas?
THank you

I've done further testing and it SD.begin(chipSelect) does not work, so it does not recognize it at all

Okay figured out it was pin 4 i needed for it to work. The serial monitor AND the sd card have strange outputs nows though,

Ex. "Lhu000ÿÿ"

it should be "5 L/hour 0:0:5";

Interestingly enough, If i comment out the line that prints to the serial monitor, it writes it to the SD card clearly

Interestingly enough, If i comment out the line that prints to the serial monitor, it writes it to the SD card clearly

Interestingly enough, there is NO line that prints to the serial monitor in the code you posted.