read function in C does not terminate

Where is your file opened? Before reading or writing to your file make sure the file is opened with proper permissions

And please check for the return value of read also.

Check the below link: http://gd.tuwien.ac.at/languages/c/programming-bbrown/c_075.htm

IMO have

printf("%s\n", buf);