Contour Lines messed up

Hi,
I am currently working on contour lines for the terrain in my game and I’m running into an issue. I have just started working with shaders and things like that and I made this simple little shader for some contour lines. but when there are flat sections, like in the image attached, its just all black. or when there are flatter sections the lines get thicker. I’ve tried doing all that I could think of and looking at the forums but I can’t find anything.

Thanks for any help!