diff --git a/lib/generator.py b/lib/generator.py index 8913c6c9..9b1f8bce 100755 --- a/lib/generator.py +++ b/lib/generator.py @@ -246,6 +246,9 @@ class Generator(): with open(os.path.join('builder-hex0', 'builder-hex0-x86-stage2.hex0'), encoding="utf-8") as infile: image_file.write(infile.read().encode()) + + # Close first with statement before getting file size. + with open(image_file_name, 'ab') as image_file: # Pad to next sector current_size = os.stat(image_file_name).st_size while current_size % 512 != 0: