sys is not need here
it is better to close file earlier