We propose a new scheme to generate flat optical frequency combs (OFCs) by the electro-optic modulation method. A digital signal is used instead of the usual RF signal to drive an electro-optic intensity modulator (IM), a band-stop filter is employed to flatten the comb lines. When suitable filter bandwidth is found, the ultra-flat optical frequency comb will be generated. The scheme can generate a large number of comb lines, the number of lines is selective, and the flatness of the comb lines is less than 0.4 dB. The comb spacing of OFCs can be adjusted by controlling the bit rate of the digital signal which is simple and easy to operate. The theoretical model of the scheme is established. Two kinds of band-stop filters (Butterworth and Gaussian) are used for comparison.