Take a look at the examples in data acquisition for streaming data to disk. This is actually quite a simple operation, but requires the use of the advanced file functions.
What you essentially have to do is open the file, start polling the se
rial device, buffer the data, store it onto the open file, and when you are done, just close the file.
The data streaming examples will give you a good idea of what to do, but be sure to substitute "write characters to file" for the binary data functions.