Add fread(length) method

Fixed off-by-one write bug