--- src/location.c
+++ src/location.c
@@ -268,6 +268,14 @@ caret_free (void)
 static bool
 caret_set_file (const char *file)
 {
+#if defined(_WIN32)
+    /* ftell() is unusable on Windows in the face of text files
+       that use just LF and not Windows-style CR-LF as newlines
+       http://support.microsoft.com/kb/68337 */
+    char fopen_mode[3] = "rb";
+#else
+    char fopen_mode[2] = "r";
+#endif
   /* If a different file than before, close and let the rest open
      the new one. */
   if (caret_info.pos.file && caret_info.pos.file != file)
@@ -278,7 +278,7 @@ caret_set_file (const char *file)
   if (!caret_info.pos.file)
     {
       caret_info.pos.file = file;
-      if ((caret_info.file = fopen (caret_info.pos.file, "r")))
+      if ((caret_info.file = fopen (caret_info.pos.file, fopen_mode)))
         {
           /* If the file is not regular (imagine #line 1 "/dev/stdin"
              in the input file for instance), don't try to quote the
