Added a length parameter to read