Moved removeCompleted function outside of writeList and now it doesn't work