public void pad(int width) throws IOException {
        int gap = (int) this.nrBits % width;
        if (gap < 0) {
            gap += width;
        }
        if (gap != 0) {
            int padding = width - gap;
            while (padding > 0) {
                this.zero();
                padding -= 1;
            }
        }
        this.out.flush();
    }