You can use a while loop that check's the value of your serial port periodically, and write it to a file using "write characters to file" function every time it changes. To know if data changes, you can use a very useful set of vi's written by Brian Renken at http://brianrenken.com
Hope this helps.