Changed to signed length to deal with -1 on error