Fix bug when collecting error messages for files