Reading data from a tty



I have been going around in circles, so if anyone can help....please!

My problem is this:
I have a serial line going to tty1, where tty1 would be receiving
data in burst.
I need to know how to read that burst of data, and then save it to a
file in the system.


Basically, it is like this:
1) the line on tty1 will send this:
AAAAAA
BBBBBB
CCCCCC
2) I need to be able to take data and write it to /tmp/inputfile


Is there some simple C program to do this?

Also, I am on an AIX machine.

.