diff --git a/Library/Homebrew/brew.h.rb b/Library/Homebrew/brew.h.rb
index 8ac1162c86fc63fc404a50156dab581bd5080999..0c901776021b18e7de499d8db51177f471fe9594 100644
--- a/Library/Homebrew/brew.h.rb
+++ b/Library/Homebrew/brew.h.rb
@@ -25,55 +25,6 @@ Mercurial can be install thusly:
   end
 end
 
-def brew_doctor
-  read, write = IO.pipe
-
-  if fork == nil
-    read.close
-    $stdout.reopen write
-    
-    bad_dylibs = Dir['/usr/local/lib/*.dylib'].select { |f| File.file? f and not File.symlink? f }
-    if bad_dylibs.count > 0
-      puts "You have unbrewed dylibs in /usr/local/lib. These could cause build problems"
-      puts "when building Homebrew formula. If you no longer need them, delete them:"
-      puts
-      puts *bad_dylibs.collect { |f| "    #{f}" }
-      puts
-    end
-
-    if gcc_build < HOMEBREW_RECOMMENDED_GCC
-      puts "Your GCC version is older than the recommended version. It may be advisable"
-      puts "to upgrade to the latest release of Xcode."
-      puts
-    end
-
-    if macports_or_fink_installed?
-      puts "You have Macports or Fink installed. This can cause trouble."
-      puts "You don't have to uninstall them, but you may like to try temporarily"
-      puts "moving them away, eg."
-      puts
-      puts "    sudo mv /opt/local ~/macports"
-      puts
-    end
-
-    unless File.exists? '/usr/X11/lib/libpng.dylib'
-      puts "You don't have X11 installed as part of your Xcode installation."
-      puts "This isn't required for all formula. But it is expected by some."
-    end
-
-    exit! 0
-  else
-    write.close
-
-    unless (out = read.read).chomp.empty?
-      puts out
-    else
-      puts "Your OS X is ripe for brewing. Any troubles you may be experiencing are"
-      puts "likely purely psychosomatic."
-    end
-  end
-end
-
 def __make url, name
   require 'formula'
   require 'digest'
diff --git a/Library/Homebrew/brew_doctor.rb b/Library/Homebrew/brew_doctor.rb
new file mode 100644
index 0000000000000000000000000000000000000000..031509dd4e183d57951bcf6f06a62832ce1a080c
--- /dev/null
+++ b/Library/Homebrew/brew_doctor.rb
@@ -0,0 +1,48 @@
+def brew_doctor
+  read, write = IO.pipe
+
+  if fork == nil
+    read.close
+    $stdout.reopen write
+    
+    bad_dylibs = Dir['/usr/local/lib/*.dylib'].select { |f| File.file? f and not File.symlink? f }
+    if bad_dylibs.count > 0
+      puts "You have unbrewed dylibs in /usr/local/lib. These could cause build problems"
+      puts "when building Homebrew formula. If you no longer need them, delete them:"
+      puts
+      puts *bad_dylibs.collect { |f| "    #{f}" }
+      puts
+    end
+
+    if gcc_build < HOMEBREW_RECOMMENDED_GCC
+      puts "Your GCC version is older than the recommended version. It may be advisable"
+      puts "to upgrade to the latest release of Xcode."
+      puts
+    end
+
+    if macports_or_fink_installed?
+      puts "You have Macports or Fink installed. This can cause trouble."
+      puts "You don't have to uninstall them, but you may like to try temporarily"
+      puts "moving them away, eg."
+      puts
+      puts "    sudo mv /opt/local ~/macports"
+      puts
+    end
+
+    unless File.exists? '/usr/X11/lib/libpng.dylib'
+      puts "You don't have X11 installed as part of your Xcode installation."
+      puts "This isn't required for all formula. But it is expected by some."
+    end
+
+    exit! 0
+  else
+    write.close
+
+    unless (out = read.read).chomp.empty?
+      puts out
+    else
+      puts "Your OS X is ripe for brewing. Any troubles you may be experiencing are"
+      puts "likely purely psychosomatic."
+    end
+  end
+end
diff --git a/bin/brew b/bin/brew
index 06960f44d4ca343021abc713a31781aad608eb12..679c66ceabce6be59958257ce0db07073fd3a346 100755
--- a/bin/brew
+++ b/bin/brew
@@ -366,6 +366,7 @@ begin
     onoe "Unknown command: #{arg} (did you mean 'git #{arg}'?)"
 
   when 'doctor'
+    require 'brew_doctor'
     brew_doctor
 
   else