diff --git a/corpus2tools/corpus-get b/corpus2tools/corpus-get
index 98a5af0b1fc6d03a7c4f9d94ac84593ff62b0ed9..8344d6bdfa6add0f695b4a78765bd4604ef200ea 100755
--- a/corpus2tools/corpus-get
+++ b/corpus2tools/corpus-get
@@ -111,7 +111,7 @@ def go():
 				return
 		else:
 			selection.update(izip(parse_range_info(arg), repeat(())))
-	maxsel = max(selection.keys())
+	maxsel = max(selection.keys()) if selection.keys() != [] else None
 	if selection == {}:
 		if options.chunks:
 			for chunk in chunks(reader):
@@ -129,7 +129,7 @@ def go():
 					else:
 						write_selected_sentences(chunk.sentences(), writer, selection[cid])
 				cid += 1
-				if cid > maxsel: break
+				if maxsel is not None and cid > maxsel: break
 		else:
 			write_selected_sentences(sentences(reader), writer, selection, maxsel)