How to fix Error 38 on Windows 11

Windows 11 Troubleshooting Guide: Error 38 – “Reached the End of the File”

Why This Error Happens

Error 38 occurs when a program attempts to read beyond the actual data stored in a file, typically because the file is truncated, corrupted, or was not closed properly during a previous write operation. This is commonly triggered by abrupt system shutdowns, disk errors, or a mismatch between the expected file size (recorded in file metadata) and the actual bytes present on disk. It can also surface when antivirus software or a failed disk sector interrupts read/write operations mid-process, leaving the file in an inconsistent state.

Step-by-Step Resolution Guide

  1. Run CHKDSK to repair file system errors
    Open Command Prompt as Administrator (search “cmd” → Run as administrator) and execute:
   chkdsk C: /f /r

Press Y to schedule the scan on next restart, then reboot your PC. This scans for and repairs corrupted sectors or file table inconsistencies causing the truncation.

  1. Check Event Viewer for the specific failing file/application
    Press Win + X → Event Viewer → navigate to Windows Logs > Application (or System). Filter by Event ID 38 and note the exact file path and source application generating the error to isolate whether it’s OS-related or application-specific.

  2. Verify system file integrity
    In an elevated Command Prompt, run:

   sfc /scannow

followed by:

   DISM /Online /Cleanup-Image /RestoreHealth

This repairs corrupted Windows system files that may be causing incomplete reads.

  1. Restore or replace the affected file
    If the error points to a specific document, log, or config file (not a system file), restore it from a previous version:
  • Right-click the file → Properties → Previous Versions tab → restore an earlier backup.
  • Alternatively, retrieve a clean copy from File History or OneDrive backup if enabled.
  1. Check disk health status
    Run wmic diskdrive get status in Command Prompt, or use Settings > System > Storage > Disks & volumes to check for “Needs attention” warnings, indicating failing hardware that repeatedly truncates files during writes.

Alternative or Verification Steps

  • After completing the steps above, reopen the file or relaunch the application that triggered Error 38 and confirm it loads/reads to completion without interruption.
  • If the error persists, use a dedicated file-repair tool appropriate to the file type (e.g., built-in repair for Office documents, or esentutl /p for database-like files) since CHKDSK only fixes disk-level issues, not internal file corruption.