add iterator to solve empty last line problem

Signed-off-by: Greg Huang <greg65236592@yahoo.com.tw>