diff --git a/ChangeLog b/ChangeLog
index 612c7a8d94fe3d8ff3856b22cf13229f1de8883f..c0c5cd3525e2b972bf871028e428240134d31482 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,8 @@ CVS Code -
 	  of winio.c.  New function rcfile.c:nregcomp().
 	  This fixes much of nano's resource hogging behavior
 	  in syntax higlighting. (David Benbennick).
+	- Fix justify failing for certain lines, new function 
+	  nano.c:breakable() (David Benbennick).
 - cut.c:
   do_cut_text()
 	- Fix incorrect cursor location when cutting long lines
diff --git a/nano.c b/nano.c
index 8a327d2c4bfbbbb006c09b241cba39e146c7860e..3286284deb548f302905f20c83965545ce827a74 100644
--- a/nano.c
+++ b/nano.c
@@ -2210,6 +2210,21 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len,
     return first_line;
 }
 
+/* Is it possible to break line at or before goal? */
+int breakable(const char *line, int goal)
+{
+    for(; *line != '\0' && goal >= 0; line++) {
+	if (*line == ' ' || *line == '\t')
+	    return TRUE;
+
+	if (is_cntrl_char(*line) != 0)
+	    goal -= 2;
+	else
+	    goal -= 1;
+    }
+    return FALSE;
+}
+
 /* We are trying to break a chunk off line.  We find the last space such
  * that the display length to there is at most goal + 1.  If there is
  * no such space, and force is not 0, then we find the first space.
@@ -2512,20 +2527,24 @@ int do_justify(void)
 	    null_at(&current->data, break_pos);
 	    current = current->next;
 	} else if (display_len < fill && par_len > 1) {
-	    size_t next_line_len = strlen(current->next->data);
+	    size_t next_line_len;
 
 	    indent_len = quote_len +
 			indent_length(current->next->data + quote_len);
-	    break_pos = break_line(current->next->data + indent_len,
-				fill - display_len - 1, 0);
-	    if (break_pos == -1)
-		/* We can't pull a word from the next line up to this one,
-		 * so just go on. */
+	    /* If we can't pull a word from the next line up to this one,
+	     * just go on. */
+	    if (!breakable(current->next->data + indent_len,
+		    fill - display_len - 1))
 		goto continue_loc;
 
 	    /* If we haven't backed up the paragraph, do it now. */
 	    if (first_mod_line == NULL)
 		first_mod_line = backup_lines(current, par_len, quote_len);
+
+	    break_pos = break_line(current->next->data + indent_len,
+				fill - display_len - 1, FALSE);
+	    assert(break_pos != -1);
+
 	    current->data = (char *)nrealloc(current->data,
 					line_len + break_pos + 2);
 	    current->data[line_len] = ' ';
@@ -2544,6 +2563,7 @@ int do_justify(void)
 		    mark_beginx -= break_pos + 1;
 	    }
 #endif
+	    next_line_len = strlen(current->next->data);
 	    if (indent_len + break_pos == next_line_len) {
 		line = current->next;
 
diff --git a/proto.h b/proto.h
index 9809362371622ac4de996b4c3dcefc275626cd49..1ab4f4de332e45443538ac8a0ba56c13eac681d0 100644
--- a/proto.h
+++ b/proto.h
@@ -300,6 +300,7 @@ size_t indents_match(const char *a_line, size_t a_indent,
 			const char *b_line, size_t b_indent);
 filestruct *backup_lines(filestruct *first_line, size_t par_len,
 			size_t quote_len);
+int breakable(const char *line, int goal);
 int break_line(const char *line, int goal, int force);
 #endif /* !DISABLE_JUSTIFY */
 int do_justify(void);