Remove duplicate code.

Use the previously unused variable (file_size) and avoid calling os.stat twice.