diff --git a/src/conio/ciolib.c b/src/conio/ciolib.c
index 01d9d54641dc2e92e01bd4329cf6c23c18d3c05c..529696e2699c397e57ab7e147d1dafab491c7634 100644
--- a/src/conio/ciolib.c
+++ b/src/conio/ciolib.c
@@ -68,7 +68,7 @@
 
 CIOLIBEXPORT cioapi_t	cio_api;
 
-static const int tabs[10]={9,17,25,33,41,49,57,65,73,80};
+static const int tabs[]={1,9,17,25,33,41,49,57,65,73,81,89,97,105,113,121,129,137,145};
 static int ungotch;
 struct text_info cio_textinfo;
 static int lastmode=3;
@@ -1097,7 +1097,7 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_putch(int a)
 			ciolib_beep();
 			break;
 		case '\t':
-			for(i=0;i<10;i++) {
+			for(i=0;i<(sizeof(tabs)/sizeof(int));i++) {
 				if(tabs[i]>cio_textinfo.curx) {
 					buf[0]=' ';
 					while(cio_textinfo.curx<tabs[i]) {
@@ -1107,11 +1107,13 @@ CIOLIBEXPORT int CIOLIBCALL ciolib_putch(int a)
 								,cio_textinfo.cury+cio_textinfo.wintop-1
 								,buf);
 						ciolib_gotoxy(cio_textinfo.curx+1,cio_textinfo.cury);
+						if(cio_textinfo.curx==cio_textinfo.screenwidth)
+							break;
 					}
 					break;
 				}
 			}
-			if(i==10) {
+			if(cio_textinfo.curx==cio_textinfo.screenwidth) {
 				ciolib_gotoxy(1,cio_textinfo.cury);
 				if(cio_textinfo.cury==cio_textinfo.winbottom-cio_textinfo.wintop+1)
 					ciolib_wscroll();
diff --git a/src/conio/cterm.c b/src/conio/cterm.c
index ff629f4237ca135b3804fc46de346fe591698edc..5650768a22f7b4c50e934f3a36b3526ea5db4f2a 100644
--- a/src/conio/cterm.c
+++ b/src/conio/cterm.c
@@ -63,7 +63,7 @@
 
 struct cterminal cterm;
 
-const int cterm_tabs[]={8,16,24,32,40,48,56,64,72,80,88,96,104,112,120,128,132,136};
+const int cterm_tabs[]={1,9,17,25,33,41,49,57,65,73,81,89,97,105,113,121,129,137,145};
 
 const char *octave="C#D#EF#G#A#B";
 
@@ -1293,26 +1293,23 @@ void ctputs(char *buf)
 			case 7:		/* Bell */
 				break;
 			case '\t':
+				*p=0;
+				cputs(outp);
+				outp=p+1;
 				for(i=0;i<sizeof(cterm_tabs)/sizeof(cterm_tabs[0]);i++) {
 					if(cterm_tabs[i]>cx) {
-						while(cx<cterm_tabs[i]) {
-							cx++;
-						}
+						cx=cterm_tabs[i];
 						break;
 					}
 				}
 				if(cx>cterm.width) {
 					cx=1;
-					if(cy==cterm.height) {
-						*p=0;
-						cputs(outp);
-						outp=p+1;
+					if(cy==cterm.height)
 						scrollup();
-						gotoxy(cx,cy);
-					}
 					else
 						cy++;
 				}
+				gotoxy(cx,cy);
 				break;
 			default:
 				if(cy==cterm.height
@@ -2012,18 +2009,6 @@ char *cterm_write(unsigned char *buf, int buflen, char *retbuf, size_t retsize,
 									prn[0]=0;
 									cterm.sequence=1;
 									break;
-								case '\t':
-									ctputs(prn);
-									prn[0]=0;
-									if(cterm.log==CTERM_LOG_ASCII && cterm.logfile != NULL)
-										fputs("\t", cterm.logfile);
-									for(k=0;k<sizeof(cterm_tabs)/sizeof(cterm_tabs[0]);k++) {
-										if(cterm_tabs[k]>wherex()) {
-											gotoxy(cterm_tabs[k],wherey());
-											break;
-										}
-									}
-									break;
 								default:
 									strcat(prn,ch);
 							}