(readname, default_index, line_size, readname): Use size_t, not int, for sizes. (readname): If the size overflows, report an error instead of looping forever.