diff --git a/src/doomtype.h b/src/doomtype.h
index 4070e346a1b13dd516a91504f056cebc4defb20d..fa8616793e0aeab7bea18c77ef78a4520770b802 100644
--- a/src/doomtype.h
+++ b/src/doomtype.h
@@ -108,6 +108,7 @@ char *nongnu_strcasestr(const char *in, const char *what);
 
 int startswith (const char *base, const char *tag);
 int endswith (const char *base, const char *tag);
+char *xstrtok(char *line, const char *delims);
 
 #if defined (_WIN32) || defined (__HAIKU__)
 #define HAVE_DOSSTR_FUNCS
diff --git a/src/string.c b/src/string.c
index 2f16fa4c68a35fa287156f546fc2973e9d4ad426..b24e12e6e36fec3078aaae76bee7a765f9c30c8f 100644
--- a/src/string.c
+++ b/src/string.c
@@ -68,3 +68,27 @@ int endswith(const char *base, const char *tag)
 
 	return !memcmp(&base[base_length - tag_length], tag, tag_length);
 }
+
+// strtok version that only skips over one delimiter at a time
+char *xstrtok(char *line, const char *delims)
+{
+	static char *saveline = NULL;
+	char *p;
+
+	if(line != NULL)
+		saveline = line;
+
+	// see if we have reached the end of the line
+	if(saveline == NULL || *saveline == '\0')
+		return NULL;
+
+	p = saveline; // save start of this token
+	
+	saveline += strcspn(saveline, delims); // get the number of non-delims characters, go past delimiter
+
+	if(*saveline != '\0') // trash the delim if necessary
+		*saveline++ = '\0';
+
+	return p;
+}
+
diff --git a/src/v_video.c b/src/v_video.c
index 6893ac30d9ee262c4a642252934d0ef69a57a8ea..7662c06df4c7f366b1ab5a4e765de7c53e86d220 100644
--- a/src/v_video.c
+++ b/src/v_video.c
@@ -2112,41 +2112,12 @@ void V_DrawFontStringAtFixed(fixed_t x, fixed_t y, INT32 option, fixed_t pscale,
 
 void V_DrawAlignedFontStringAtFixed(fixed_t x, fixed_t y, INT32 option, fixed_t pscale, fixed_t vscale, const char *string, fontdef_t font, enum string_align align)
 {
-	char line[MAXLINELEN];
-	size_t i, start = 0;
+	char *text = strdup(string);
+	char* line = xstrtok(text, "\n");
 	fixed_t lx = x, ly = y;
 
-	while (*(string+start))
+	while (line)
 	{
-		for (i = 0; i < strlen(string+start); i++)
-		{
-			if (*(string+start+i) == '\n')
-			{
-				memset(line, 0, MAXLINELEN);
-				if (i >= MAXLINELEN) 
-				{
-					CONS_Printf("V_DrawAlignedFontStringAtFixed: a line exceeds max. length %d (string: %s)\n", MAXLINELEN, string);
-					return;
-				}
-				strncpy(line,string + start, i);
-				line[i] = '\0';
-				start += i + 1;
-				i = (size_t)-1; //added : 07-02-98 : damned!
-				break;
-			}
-		}
-
-		if (i == strlen(string + start))
-		{
-			if (i >= MAXLINELEN) 
-			{
-				CONS_Printf("V_DrawAlignedFontStringAtFixed: a line exceeds max. length %d (string: %s)\n", MAXLINELEN, string);
-				return;
-			}
-			strcpy(line, string + start);
-			start += i;
-		}
-
 		switch(align)
 		{
 			case alignleft:
@@ -2163,6 +2134,8 @@ void V_DrawAlignedFontStringAtFixed(fixed_t x, fixed_t y, INT32 option, fixed_t
 		V_DrawFontStringAtFixed(lx, ly, option, pscale, vscale, line, font);
 
 		ly += FixedMul(((option & V_RETURN8) ? 8 : font.linespacing)<<FRACBITS, vscale);
+
+		line = xstrtok(NULL, "\n");
 	}
 }