bug fix: check bread() return value