Add EOF new line and moved the toString function