Fixing range error, trying to read bytes that don't exist