bitc_stdio_read_byte and bitc_stdio_write_byte check success via fread/fwrite < 0, however both have the return type size_t and thus the check never fails. It should be 1 instead of 0 in both cases. In addition neither of them check if the file actually is open (NULL == ios->f) and thus segfault if the stream has been closed. Thomas