thread separat, modularizare, writeToFile