docs: private int readLine() throws IOException {
  		// end of file reached
  		if (pos == -1)
  			return 0;
  		final InputStream in = this.in;
  
  		// temporary value
  		int b;
  
  		int lineSize, type, offset;
  		do {
  			// skip end of line
  			do {
  				b = in.read();
  				pos++;
  			} while (b == '\n' || b == '\r');
  
  			/*
  			 * Each line starts with comma (':')
  			 * Data is written in HEX, so each 2 ASCII letters give one byte.
  			 * After the comma there is one byte (2 HEX signs) with line length
  			 * (normally 10 -> 0x10 -> 16 bytes -> 32 HEX characters)
  			 * After that there is a 4 byte of an address. This part may be skipped.
  			 * There is a packet type after the address (1 byte = 2 HEX characters).
  			 * 00 is the valid data. Other values can be skipped when converting to BIN file.
  			 * Then goes n bytes of data followed by 1 byte (2 HEX chars) of checksum,
  			 * which is also skipped in BIN file.
  			 */
  			checkComma(b); // checking the comma at the beginning
  			lineSize = readByte(in); // reading the length of the data in this line
  			pos += 2;
  			offset = readAddress(in);// reading the offset
  			pos += 4;
  			type = readByte(in); // reading the line type
  			pos += 2;
  
  			// if the line type is no longer data type (0x00), we've reached the end of the file
  			switch (type) {
  				case 0x00:
  					// data type
  					if (lastAddress + offset < MBRSize) { // skip MBR
  						type = -1; // some other than 0
  						pos += skip(in, lineSize * 2 /* 2 hex per one byte */ + 2 /* check sum */);
  					}
  					break;
  				case 0x01:
  					// end of file
  					pos = -1;
  					return 0;
  				case 0x02: {
  					// extended segment address
  					final int address = readAddress(in) << 4;
  					pos += 4;
  					if (bytesRead > 0 && (address >> 16) != (lastAddress >> 16) + 1)
  						return 0;
  					lastAddress = address;
  					pos += skip(in, 2 /* check sum */);
  					break;
  				}
  				case 0x04: {
  					// extended linear address
  					final int address = readAddress(in);
  					pos += 4;
  					if (bytesRead > 0 && address != (lastAddress >> 16) + 1)
  						return 0;
  					lastAddress = address << 16;
  					pos += skip(in, 2 /* check sum */);
  					break;
  				}
  				default:
  					final long toBeSkipped = lineSize * 2 /* 2 hex per one byte */ + 2 /* check sum */;
  					pos += skip(in, toBeSkipped);
  					break;
  			}
  		} while (type != 0);
  
  		// otherwise read lineSize bytes or fill the whole buffer
  		for (int i = 0; i < localBuf.length && i < lineSize; ++i) {
  			b = readByte(in);
  			pos += 2;
  			localBuf[i] = (byte) b;
  		}
  		pos += skip(in, 2); // skip the checksum
  		localPos = 0;
  
  		return lineSize;
  	}