Serial Read Data Loss With Arduino Nano
You are overflowing your buffer, and also allowing garbage reads.

First you need 5 bytes for your buffer not 4, and you need to ensure it is zeroed out before using it. This is because you are treating it like a C string, which means it must b zero terminated.

Secondly your use of Serial.readBytesUntil() is flawed.  From the manual:


  The function terminates (checks being done in this order) if the determined length has been read, if it times out (see Serial.setTimeout()), or if the terminator character is detected (in which case the function returns the characters up to the last character before the supplied terminator).


You are sending 5 bytes (1058\n) but telling it to read up to 4. Which leaves the \n in the buffer. The next time through you read another 4 bytes, which gives you \n which is the terminating character. 

If you must use readBytesUntil then you need to specify a buffer that is bigger than the whole string including the terminator so that the terminator always occurs before the maximum number of bytes read. Including the trailing zero you would thus need at least 6 bytes in your buffer, maybe a couple more "just in case" (one can never tell with Arduino API functions...)

So to roll it all up:

  char buffer[8]; // &lt;- Bigger buffer
  memset(buffer, 0, 8); // &lt;- Clear it out
  int deger = 0;
  if (Serial.available() &gt; 0) {
    int size = Serial.readBytesUntil('\n', buffer, 7); // &lt;- Tell it to read more leaving room for the terminating NULL
    ... etc ...


if (size == 4) {