--- ray/src/util/rcollate.c 2014/05/30 18:10:20 2.12 +++ ray/src/util/rcollate.c 2014/05/30 18:24:06 2.13 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rcollate.c,v 2.12 2014/05/30 18:10:20 greg Exp $"; +static const char RCSid[] = "$Id: rcollate.c,v 2.13 2014/05/30 18:24:06 greg Exp $"; #endif /* * Utility to re-order records in a binary or ASCII data file (matrix) @@ -237,11 +237,11 @@ output_stream(FILE *fp) if (fp == NULL) return(0); - fflush(stdout); /* assumes nothing in input buffer */ - while ((n = read(fileno(fp), buf, sizeof(buf))) > 0) + fflush(stdout); + while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) if (write(fileno(stdout), buf, n) != n) return(0); - return(n >= 0); + return(!ferror(fp)); } /* get next word from stream, leaving stream on EOL or start of next word */