diff --git a/src/sbbs3/writemsg.cpp b/src/sbbs3/writemsg.cpp
index 5c3434602390a873ed862b8a5c0e947783a7d94e..f06d8fc76de1c806966492946aafd9319756c48b 100644
--- a/src/sbbs3/writemsg.cpp
+++ b/src/sbbs3/writemsg.cpp
@@ -1278,7 +1278,7 @@ bool sbbs_t::editfile(char *fname, bool msg)
 	}
 	if((file=nopen(fname,O_RDONLY))!=-1) {
 		length=(long)filelength(file);
-		if(length>(long)maxlines*MAX_LINE_LEN) {
+		if(length < 0 || length>(long)maxlines*MAX_LINE_LEN) {
 			close(file);
 			free(buf); 
 			attr(cfg.color[clr_err]);