diff --git a/lib/mpd_client.rb b/lib/mpd_client.rb
index 6c2c82d..7ae934d 100644
--- a/lib/mpd_client.rb
+++ b/lib/mpd_client.rb
@@ -302,6 +302,8 @@ module MPD
def read_line
line = @socket.gets
+ return if line.nil?
+
raise 'Connection lost while reading line' unless line.end_with?("\n")
if line.start_with?(ERROR_PREFIX)