Show the source code of failing tests on errors.
diff --git a/Makefile b/Makefile
index 7cda2de..082e8d8 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@
 
 ifneq ($(BADFMT),)
 ifneq ($(MAKECMDGOALS),gofmt)
-$(warning WARNING: make gofmt: $(BADFMT))
+#$(warning WARNING: make gofmt: $(BADFMT))
 endif
 endif
 
diff --git a/fixture_test.go b/fixture_test.go
index 1b9bdb6..217bc64 100644
--- a/fixture_test.go
+++ b/fixture_test.go
@@ -404,7 +404,7 @@
             "FAIL: fixture_test\\.go:[0-9]+: "+
             "FixtureCheckHelper\\.SetUpSuite\n\n"+
             "fixture_test\\.go:[0-9]+:\n"+
-            "\\.+ Check\\(obtained, Equals, expected\\):\n"+
+            "    c\\.Check\\(false, Equals, true\\)\n"+
             "\\.+ obtained = \\(bool\\) false\n"+
             "\\.+ expected = \\(bool\\) true\n\n")
     c.Assert(helper.completed, Equals, true)
@@ -419,7 +419,7 @@
             "FAIL: fixture_test\\.go:[0-9]+: "+
             "FixtureCheckHelper\\.SetUpSuite\n\n"+
             "fixture_test\\.go:[0-9]+:\n"+
-            "\\.+ Assert\\(obtained, Equals, expected\\):\n"+
+            "    c\\.Assert\\(false, Equals, true\\)\n"+
             "\\.+ obtained = \\(bool\\) false\n"+
             "\\.+ expected = \\(bool\\) true\n\n")
     c.Assert(helper.completed, Equals, false)
diff --git a/foundation_test.go b/foundation_test.go
index c7a8418..8636b67 100644
--- a/foundation_test.go
+++ b/foundation_test.go
@@ -28,7 +28,8 @@
 func (s *FoundationS) TestErrorf(c *gocheck.C) {
     // Do not use checkState() here.  It depends on Errorf() working.
     expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
-        "... Error: Error message!\n",
+        "    c.Errorf(\"Error %%v!\", \"message\")\n"+
+        "... Error: Error message!\n\n",
         getMyLine()+1)
     c.Errorf("Error %v!", "message")
     failed := c.Failed()
@@ -45,7 +46,8 @@
 
 func (s *FoundationS) TestError(c *gocheck.C) {
     expectedLog := fmt.Sprintf("foundation_test.go:%d:\n"+
-        "... Error: Error message!\n",
+        "    c\\.Error\\(\"Error \", \"message!\"\\)\n"+
+        "\\.\\.\\. Error: Error message!\n\n",
         getMyLine()+1)
     c.Error("Error ", "message!")
     checkState(c, nil,
@@ -112,10 +114,11 @@
         } else {
             c.Succeed()
             expected := fmt.Sprintf("foundation_test.go:%d:\n"+
-                "... Error: Die now!\n",
+                "    c.Fatal(\"Die \", \"now!\")\n"+
+                "... Error: Die now!\n\n",
                 line)
             if c.GetTestLog() != expected {
-                c.Error("Incorrect log:\n" + c.GetTestLog())
+                c.Error("Incorrect log:", c.GetTestLog())
             }
         }
     })()
@@ -133,10 +136,11 @@
         } else {
             c.Succeed()
             expected := fmt.Sprintf("foundation_test.go:%d:\n"+
-                "... Error: Die now!\n",
+                "    c.Fatalf(\"Die %%s!\", \"now\")\n"+
+                "... Error: Die now!\n\n",
                 line)
             if c.GetTestLog() != expected {
-                c.Error("Incorrect log:\n" + c.GetTestLog())
+                c.Error("Incorrect log:", c.GetTestLog())
             }
         }
     })()
@@ -149,8 +153,8 @@
 
 func (s *FoundationS) TestCallerLoggingInsideTest(c *gocheck.C) {
     log := fmt.Sprintf(""+
-        "foundation_test.go:%d:\n"+ //"    result := c.Check(10, gocheck.Equals, 20)\n"+
-        "\\.\\.\\. Check\\(obtained, Equals, expected\\):\n"+
+        "foundation_test.go:%d:\n"+
+        "    result := c.Check\\(10, gocheck.Equals, 20\\)\n"+
         "\\.\\.\\. obtained = \\(int\\) 10\n"+
         "\\.\\.\\. expected = \\(int\\) 20\n\n",
         getMyLine()+1)
@@ -168,8 +172,10 @@
     result, line := checkEqualWrapper(c, 10, 20)
     testLine := getMyLine() - 1
     log := fmt.Sprintf(""+
-        "foundation_test.go:%d > gocheck_test.go:%d:\n"+
-        "\\.\\.\\. Check\\(obtained, Equals, expected\\):\n"+
+        "foundation_test.go:%d:\n"+
+        "    result, line := checkEqualWrapper\\(c, 10, 20\\)\n"+
+        "gocheck_test.go:%d:\n"+
+        "    return c.Check\\(obtained, gocheck.Equals, expected\\), getMyLine\\(\\)\n"+
         "\\.\\.\\. obtained = \\(int\\) 10\n"+
         "\\.\\.\\. expected = \\(int\\) 20\n\n",
         testLine, line)
diff --git a/gocheck.go b/gocheck.go
index 22e72d2..cca80db 100644
--- a/gocheck.go
+++ b/gocheck.go
@@ -168,36 +168,48 @@
     c.log("... ", issue)
 }
 
-func (c *C) logCaller(skip int, issue string) {
+func (c *C) logCaller(skip int) {
     // This is a bit heavier than it ought to be.
     skip += 1 // Our own frame.
-    if pc, callerFile, callerLine, ok := runtime.Caller(skip); ok {
-        var testFile string
-        var testLine int
-        testFunc := runtime.FuncForPC(c.method.Get())
-        if runtime.FuncForPC(pc) != testFunc {
-            for {
-                skip += 1
-                if pc, file, line, ok := runtime.Caller(skip); ok {
-                    // Note that the test line may be different on
-                    // distinct calls for the same test.  Showing
-                    // the "internal" line is helpful when debugging.
-                    if runtime.FuncForPC(pc) == testFunc {
-                        testFile, testLine = file, line
-                        break
-                    }
-                } else {
+    pc, callerFile, callerLine, ok := runtime.Caller(skip)
+    if !ok {
+        return
+    }
+    var testFile string
+    var testLine int
+    testFunc := runtime.FuncForPC(c.method.Get())
+    if runtime.FuncForPC(pc) != testFunc {
+        for {
+            skip += 1
+            if pc, file, line, ok := runtime.Caller(skip); ok {
+                // Note that the test line may be different on
+                // distinct calls for the same test.  Showing
+                // the "internal" line is helpful when debugging.
+                if runtime.FuncForPC(pc) == testFunc {
+                    testFile, testLine = file, line
                     break
                 }
+            } else {
+                break
             }
         }
-        if testFile != "" && (testFile != callerFile || testLine != callerLine) {
-            c.logf("%s:%d > %s:%d:\n... %s", nicePath(testFile), testLine,
-                nicePath(callerFile), callerLine, issue)
-        } else {
-            c.logf("%s:%d:\n... %s", nicePath(callerFile), callerLine, issue)
+    }
+    if testFile != "" && (testFile != callerFile || testLine != callerLine) {
+        c.logCode(testFile, testLine)
+    }
+    c.logCode(callerFile, callerLine)
+}
+
+func (c *C) logCode(path string, line int) {
+    c.logf("%s:%d:", nicePath(path), line)
+    code, err := printLine(path, line)
+    if code == "" {
+        code = "..." // XXX Open the file and take the raw line.
+        if err != nil {
+            code += err.String()
         }
     }
+    c.log(indent(code, "    "))
 }
 
 func (c *C) logPanic(skip int, value interface{}) {
diff --git a/gocheck_test.go b/gocheck_test.go
index 1f01f42..17ed0b0 100644
--- a/gocheck_test.go
+++ b/gocheck_test.go
@@ -69,10 +69,8 @@
 
 // Trivial wrapper to test errors happening on a different file
 // than the test itself.
-func checkEqualWrapper(c *gocheck.C,
-expected interface{},
-obtained interface{}) (result bool, line int) {
-    return c.Check(expected, gocheck.Equals, obtained), getMyLine()
+func checkEqualWrapper(c *gocheck.C, obtained, expected interface{}) (result bool, line int) {
+    return c.Check(obtained, gocheck.Equals, expected), getMyLine()
 }
 
 
diff --git a/helpers.go b/helpers.go
index 198e4b8..4a5076f 100644
--- a/helpers.go
+++ b/helpers.go
@@ -94,7 +94,9 @@
 // The provided arguments will be assembled together into a string using
 // fmt.Sprint().
 func (c *C) Error(args ...interface{}) {
-    c.logCaller(1, fmt.Sprint("Error: ", fmt.Sprint(args...)))
+    c.logCaller(1)
+    c.logString(fmt.Sprint("Error: ", fmt.Sprint(args...)))
+    c.logNewLine()
     c.Fail()
 }
 
@@ -102,7 +104,9 @@
 // The provided arguments will be assembled together into a string using
 // fmt.Sprintf().
 func (c *C) Errorf(format string, args ...interface{}) {
-    c.logCaller(1, fmt.Sprintf("Error: "+format, args...))
+    c.logCaller(1)
+    c.logString(fmt.Sprintf("Error: "+format, args...))
+    c.logNewLine()
     c.Fail()
 }
 
@@ -110,7 +114,9 @@
 // stop the test execution. The provided arguments will be assembled
 // together into a string using fmt.Sprint().
 func (c *C) Fatal(args ...interface{}) {
-    c.logCaller(1, fmt.Sprint("Error: ", fmt.Sprint(args...)))
+    c.logCaller(1)
+    c.logString(fmt.Sprint("Error: ", fmt.Sprint(args...)))
+    c.logNewLine()
     c.FailNow()
 }
 
@@ -118,7 +124,9 @@
 // stop the test execution. The provided arguments will be assembled
 // together into a string using fmt.Sprintf().
 func (c *C) Fatalf(format string, args ...interface{}) {
-    c.logCaller(1, fmt.Sprint("Error: ", fmt.Sprintf(format, args...)))
+    c.logCaller(1)
+    c.logString(fmt.Sprint("Error: ", fmt.Sprintf(format, args...)))
+    c.logNewLine()
     c.FailNow()
 }
 
@@ -152,7 +160,8 @@
 
 func (c *C) internalCheck(funcName string, obtained interface{}, checker Checker, args ...interface{}) bool {
     if checker == nil {
-        c.logCaller(2, fmt.Sprintf("%s(obtained, nil!?, ...):", funcName))
+        c.logCaller(2)
+        c.logString(fmt.Sprintf("%s(obtained, nil!?, ...):", funcName))
         c.logString("Oops.. you've provided a nil checker!")
         goto fail
     }
@@ -180,12 +189,10 @@
         }
     } else {
         obtainedName, expectedName := checker.VarNames()
-        c.logCaller(2, fmt.Sprintf("%s(%s, %s, >%s<):", funcName, obtainedName,
-            checker.Name(), expectedName))
-        c.logString(fmt.Sprintf("Wrong number of %s args for %s: "+
-            "want %d, got %d",
-            expectedName, checker.Name(),
-            expectedWanted, len(args)))
+        c.logCaller(2)
+        c.logString(fmt.Sprintf("%s(%s, %s, >%s<):", funcName, obtainedName, checker.Name(), expectedName))
+        c.logString(fmt.Sprintf("Wrong number of %s args for %s: want %d, got %d",
+            expectedName, checker.Name(), expectedWanted, len(args)))
         goto fail
     }
 
@@ -193,15 +200,7 @@
     result, error := checker.Check(obtained, expected)
     if !result || error != "" {
         obtainedName, expectedName := checker.VarNames()
-        var summary string
-        if expectedWanted > 0 {
-            summary = fmt.Sprintf("%s(%s, %s, %s):", funcName, obtainedName,
-                checker.Name(), expectedName)
-        } else {
-            summary = fmt.Sprintf("%s(%s, %s):", funcName, obtainedName,
-                checker.Name())
-        }
-        c.logCaller(2, summary)
+        c.logCaller(2)
         c.logValue(obtainedName, obtained)
         if expectedWanted > 0 {
             c.logValue(expectedName, expected)
diff --git a/helpers_test.go b/helpers_test.go
index b710f14..9068bb9 100644
--- a/helpers_test.go
+++ b/helpers_test.go
@@ -96,8 +96,8 @@
 
 func (s *HelpersS) TestCheckFailWithExpected(c *gocheck.C) {
     checker := &MyChecker{failCheck: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
-        "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    return c\\.Check\\(1, checker, 2\\)\n" +
         "\\.+ myobtained = \\(int\\) 1\n" +
         "\\.+ myexpected = \\(int\\) 2\n\n"
     testHelperFailure(c, "Check(1, checker, 2)", false, false, log,
@@ -108,8 +108,8 @@
 
 func (s *HelpersS) TestCheckFailWithExpectedAndBugInfo(c *gocheck.C) {
     checker := &MyChecker{failCheck: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
-        "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    return c\\.Check\\(1, checker, 2, myBug\\(\"Hello world!\"\\)\\)\n" +
         "\\.+ myobtained = \\(int\\) 1\n" +
         "\\.+ myexpected = \\(int\\) 2\n" +
         "\\.+ Hello world!\n\n"
@@ -121,8 +121,8 @@
 
 func (s *HelpersS) TestCheckFailWithoutExpected(c *gocheck.C) {
     checker := &MyChecker{failCheck: true, noExpectedValue: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
-        "\\.+ Check\\(myobtained, MyChecker\\):\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    return c\\.Check\\(1, checker\\)\n" +
         "\\.+ myobtained = \\(int\\) 1\n\n"
     testHelperFailure(c, "Check(1, checker)", false, false, log,
         func() interface{} {
@@ -132,8 +132,8 @@
 
 func (s *HelpersS) TestCheckFailWithoutExpectedAndMessage(c *gocheck.C) {
     checker := &MyChecker{failCheck: true, noExpectedValue: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
-        "\\.+ Check\\(myobtained, MyChecker\\):\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    return c\\.Check\\(1, checker, myBug\\(\"Hello world!\"\\)\\)\n" +
         "\\.+ myobtained = \\(int\\) 1\n" +
         "\\.+ Hello world!\n\n"
     testHelperFailure(c, "Check(1, checker, msg)", false, false, log,
@@ -144,7 +144,8 @@
 
 func (s *HelpersS) TestCheckWithMissingExpected(c *gocheck.C) {
     checker := &MyChecker{failCheck: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    return c\\.Check\\(1, checker\\)\n" +
         "\\.+ Check\\(myobtained, MyChecker, >myexpected<\\):\n" +
         "\\.+ Wrong number of myexpected args for MyChecker: " +
         "want 1, got 0\n\n"
@@ -156,7 +157,8 @@
 
 func (s *HelpersS) TestCheckWithTooManyExpected(c *gocheck.C) {
     checker := &MyChecker{noExpectedValue: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    return c\\.Check\\(1, checker, 1\\)\n" +
         "\\.+ Check\\(myobtained, MyChecker, >myexpected<\\):\n" +
         "\\.+ Wrong number of myexpected args for MyChecker: " +
         "want 0, got 1\n\n"
@@ -168,8 +170,8 @@
 
 func (s *HelpersS) TestCheckWithError(c *gocheck.C) {
     checker := &MyChecker{checkError: "Some not so cool data provided!"}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
-        "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    return c\\.Check\\(1, checker, 2\\)\n" +
         "\\.+ myobtained = \\(int\\) 1\n" +
         "\\.+ myexpected = \\(int\\) 2\n" +
         "\\.+ Some not so cool data provided!\n\n"
@@ -180,7 +182,8 @@
 }
 
 func (s *HelpersS) TestCheckWithNilChecker(c *gocheck.C) {
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    return c\\.Check\\(1, nil\\)\n" +
         "\\.+ Check\\(obtained, nil!\\?, \\.\\.\\.\\):\n" +
         "\\.+ Oops\\.\\. you've provided a nil checker!\n\n"
     testHelperFailure(c, "Check(obtained, nil)", false, false, log,
@@ -219,8 +222,8 @@
 
 func (s *HelpersS) TestAssertFailWithExpected(c *gocheck.C) {
     checker := &MyChecker{failCheck: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
-        "\\.+ Assert\\(myobtained, MyChecker, myexpected\\):\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    c\\.Assert\\(1, checker, 2\\)\n" +
         "\\.+ myobtained = \\(int\\) 1\n" +
         "\\.+ myexpected = \\(int\\) 2\n\n"
     testHelperFailure(c, "Assert(1, checker, 2)", nil, true, log,
@@ -232,8 +235,8 @@
 
 func (s *HelpersS) TestAssertFailWithExpectedAndMessage(c *gocheck.C) {
     checker := &MyChecker{failCheck: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
-        "\\.+ Assert\\(myobtained, MyChecker, myexpected\\):\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    c\\.Assert\\(1, checker, 2, myBug\\(\"Hello world!\"\\)\\)\n" +
         "\\.+ myobtained = \\(int\\) 1\n" +
         "\\.+ myexpected = \\(int\\) 2\n" +
         "\\.+ Hello world!\n\n"
@@ -246,8 +249,8 @@
 
 func (s *HelpersS) TestAssertFailWithoutExpected(c *gocheck.C) {
     checker := &MyChecker{failCheck: true, noExpectedValue: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
-        "\\.+ Assert\\(myobtained, MyChecker\\):\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    c\\.Assert\\(1, checker\\)\n" +
         "\\.+ myobtained = \\(int\\) 1\n\n"
     testHelperFailure(c, "Assert(1, checker)", nil, true, log,
         func() interface{} {
@@ -258,8 +261,8 @@
 
 func (s *HelpersS) TestAssertFailWithoutExpectedAndMessage(c *gocheck.C) {
     checker := &MyChecker{failCheck: true, noExpectedValue: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
-        "\\.+ Assert\\(myobtained, MyChecker\\):\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    c\\.Assert\\(1, checker, myBug\\(\"Hello world!\"\\)\\)\n" +
         "\\.+ myobtained = \\(int\\) 1\n" +
         "\\.+ Hello world!\n\n"
     testHelperFailure(c, "Assert(1, checker, msg)", nil, true, log,
@@ -271,7 +274,8 @@
 
 func (s *HelpersS) TestAssertWithMissingExpected(c *gocheck.C) {
     checker := &MyChecker{failCheck: true}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    c\\.Assert\\(1, checker\\)\n" +
         "\\.+ Assert\\(myobtained, MyChecker, >myexpected<\\):\n" +
         "\\.+ Wrong number of myexpected args for MyChecker: " +
         "want 1, got 0\n\n"
@@ -284,8 +288,8 @@
 
 func (s *HelpersS) TestAssertWithError(c *gocheck.C) {
     checker := &MyChecker{checkError: "Some not so cool data provided!"}
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
-        "\\.+ Assert\\(myobtained, MyChecker, myexpected\\):\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    c\\.Assert\\(1, checker, 2\\)\n" +
         "\\.+ myobtained = \\(int\\) 1\n" +
         "\\.+ myexpected = \\(int\\) 2\n" +
         "\\.+ Some not so cool data provided!\n\n"
@@ -297,7 +301,8 @@
 }
 
 func (s *HelpersS) TestAssertWithNilChecker(c *gocheck.C) {
-    log := "helpers_test\\.go:[0-9]+ > helpers_test\\.go:[0-9]+:\n" +
+    log := "helpers_test\\.go:[0-9]+:.*\nhelpers_test\\.go:[0-9]+:\n" +
+        "    c\\.Assert\\(1, nil\\)\n" +
         "\\.+ Assert\\(obtained, nil!\\?, \\.\\.\\.\\):\n" +
         "\\.+ Oops\\.\\. you've provided a nil checker!\n\n"
     testHelperFailure(c, "Assert(obtained, nil)", nil, true, log,
@@ -313,8 +318,8 @@
 
 func (s *HelpersS) TestValueLoggingWithArrays(c *gocheck.C) {
     checker := &MyChecker{failCheck: true}
-    log := "helpers_test.go:[0-9]+ > helpers_test.go:[0-9]+:\n" +
-        "\\.+ Check\\(myobtained, MyChecker, myexpected\\):\n" +
+    log := "helpers_test.go:[0-9]+:.*\nhelpers_test.go:[0-9]+:\n" +
+        "    return c\\.Check\\(\\[\\]byte{1, 2}, checker, \\[\\]byte{1, 3}\\)\n" +
         "\\.+ myobtained = \\(\\[\\]uint8\\) \\[\\]byte{0x1, 0x2}\n" +
         "\\.+ myexpected = \\(\\[\\]uint8\\) \\[\\]byte{0x1, 0x3}\n\n"
     testHelperFailure(c, "Check([]byte{1}, chk, []byte{3})", false, false, log,
diff --git a/printer.go b/printer.go
index b7e3acc..6e4a444 100644
--- a/printer.go
+++ b/printer.go
@@ -43,28 +43,45 @@
 }
 
 type linePrinter struct {
-    fset *token.FileSet
-    line int
-    output bytes.Buffer
-    stmt ast.Stmt
     config *printer.Config
+    fset   *token.FileSet
+    line   int
+    output bytes.Buffer
+    stmt   ast.Stmt
+}
+
+func (lp *linePrinter) emit() bool {
+    if lp.stmt != nil {
+        lp.trim(lp.stmt)
+        lp.config.Fprint(&lp.output, lp.fset, lp.stmt)
+        lp.stmt = nil
+        return true
+    }
+    return false
 }
 
 func (lp *linePrinter) Visit(n ast.Node) (w ast.Visitor) {
     if n == nil {
+        if lp.output.Len() == 0 {
+            lp.emit()
+        }
         return nil
     }
-    if stmt, ok := n.(ast.Stmt); ok {
-        lp.stmt = stmt
+    first := lp.fset.Position(n.Pos()).Line
+    last := lp.fset.Position(n.End()).Line
+    if first <= lp.line && last >= lp.line {
+        // Print the innermost statement containing the line.
+        if stmt, ok := n.(ast.Stmt); ok {
+            if _, ok := n.(*ast.BlockStmt); !ok {
+                lp.stmt = stmt
+            }
+        }
+        if first == lp.line && lp.emit() {
+            return nil
+        }
+        return lp
     }
-    p := n.Pos()
-    line := lp.fset.Position(p).Line
-    if line == lp.line {
-        lp.trim(lp.stmt)
-        lp.config.Fprint(&lp.output, lp.fset, lp.stmt)
-        return nil
-    }
-    return lp
+    return nil
 }
 
 func (lp *linePrinter) trim(n ast.Node) bool {
@@ -72,8 +89,7 @@
     if !ok {
         return true
     }
-    p := n.Pos()
-    line := lp.fset.Position(p).Line
+    line := lp.fset.Position(n.Pos()).Line
     if line != lp.line {
         return false
     }
diff --git a/printer_test.go b/printer_test.go
index 3cafd4b..81e51c6 100644
--- a/printer_test.go
+++ b/printer_test.go
@@ -1,7 +1,7 @@
 package gocheck_test
 
 import (
-    . "gocheck"
+    .   "gocheck"
 )
 
 var _ = Suite(&PrinterS{})
@@ -24,24 +24,38 @@
         println(3)
     }
     switch 5 {
-    case 6: println(6)
+    case 6:
+        println(6)
         println(7)
     }
     switch interface{}(9).(type) {
-    case int: println(10)
+    case int:
+        println(10)
         println(11)
     }
     select {
-    case <-(chan bool)(nil): println(14)
+    case <-(chan bool)(nil):
+        println(14)
         println(15)
-    default: println(16)
+    default:
+        println(16)
         println(17)
     }
     println(19,
         20)
+    _ = func() {
+        println(21)
+        println(22)
+    }
+    println(24, func() {
+        println(25)
+    })
 }
 
-var printLineTests = []struct{line int; output string}{
+var printLineTests = []struct {
+    line   int
+    output string
+}{
     {1, "println(1)"},
     {2, "if 2 == 2 {\n    ...\n}"},
     {3, "println(3)"},
@@ -55,6 +69,12 @@
     {16, "default:\n    println(16)\n    ..."},
     {17, "println(17)"},
     {19, "println(19,\n    20)"},
+    {20, "println(19,\n    20)"},
+    {21, "_ = func() {\n    println(21)\n    println(22)\n}"},
+    {22, "println(22)"},
+    {24, "println(24, func() {\n    println(25)\n})"},
+    {25, "println(25)"},
+    {26, "println(24, func() {\n    println(25)\n})"},
 }
 
 func (s *PrinterS) TestPrintLine(c *C) {
@@ -65,7 +85,9 @@
     }
 }
 
-var indentTests = []struct{in, out string}{
+var indentTests = []struct {
+    in, out string
+}{
     {"", ""},
     {"\n", "\n"},
     {"a", ">>>a"},