Fix size of control file generated after rewind

Use a proper zero-padded buffer to write control file and prevent
EOF-related errors that may occur when reading it.