Dear Stata Users

I have been running a loop for each out of 5 years.

Code:
clear all
cd "\\registry\2017"
save appended_2017, emptyok
local filelist: dir . files "*.dta"
foreach f of local filelist {
  use `f', clear
  append using appended_2017.dta
  save appended_2017.dta, replace
  }
It worked well for 3 years (2014, 2015, 2016). For some unkown to me reason it produces an error for year 2017 and 2018.
All files are sitting in the corresponding year folder.

Error:
no variables defined
r(111);
Any idea of what is causing an error?

Thank you.