Added prototype and fixed generic, naive implementation of buf_fgets.