changing not not to not empty check
created a generic writer and working loopFrom condition