diff --git a/src/sbbs3/writemsg.cpp b/src/sbbs3/writemsg.cpp
index 20102172c20df912f8d62af4ef821a070ed4d063..86a07336c31cfb626b2240a15c3a70d8ad55c7e9 100644
--- a/src/sbbs3/writemsg.cpp
+++ b/src/sbbs3/writemsg.cpp
@@ -385,7 +385,10 @@ bool sbbs_t::writemsg(char *fname, char *top, char *title, long mode, int subnum
 		/* Strip FidoNet Kludge Lines? */
 		if(buf[l]==1 && useron.xedit
 			&& cfg.xedit[useron.xedit-1]->misc&STRIPKLUDGE) {
-			while(buf[l]!=LF) l++;
+			while(buf[l] && buf[l]!=LF) 
+				l++;
+			if(buf[l]==0)
+				break;
 			continue;
 		}
 		if(!(mode&(WM_EMAIL|WM_NETMAIL))