This is likely to be linked to fractional pixel co-ordinates and the way it can be rounded by OpenGL.
You could try the
half-pixel trick: add 0.5 to both the x and y co-ordinate, placing the position in the middle of the pixel, allowing the outline to start from the same place on each side (stays within same pixel at less than 0.5).
That said, a more robust solution is create a your grid using a
vertex array.
You can create the grid of lines with a single vertex array (and just the full lines themselves) but remember to use the half-pixel trick above as the lines should go through the centre of the pixels.
If you also have rectangles/boxes/quads to draw inbetween those gridlines, you can use a vertex array to display all of those too. Just add multiple quads. You could take inspiration from the
tile map example.
NOTE: it's important that the half-pixel trick above is actually half of a pixel - not just half a unit - so if your co-ordinate system is not 1:1 to the pixels, you will need to adjust for this.