this has write to file feature too