How can I get rid of the gaps in lines for an infinite grid?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Struns

I am trying to make an infinite grid similar to the one in the editor.

enter image description here

I am using a shader, but the lines have gaps in them if they are further away.

enter image description here

How can I fix that? I would like a grid of 1 pixel lines everywhere like the first image.