The following sequence of subroutine calls illustrate a simple example of writing a new FITS file:
1. Create the new file with FTINIT. 2. Write the required primary array keywords with FTPHPR. 3. Write any additional keywords with FTPKYx. 4. Write the primary array data, if any, with FTPPRx. 5. Create another extension, if desired, with FTCRHD. 6. Write required header keywords for the extension with FTPHTB or FTPHBN. 7. Write any additional keywords with FTPKYx 8. Write data to the extension, one column at a time with FTPCLx 9. Repeat steps 5 - 8 for any more extensions. 10. Close the FITS file with FTCLOSNote that the application program must not explicitly write the required 'END' keyword at the end of each header; the FITSIO interface will automatically append the END record whenever the header is closed. As a standard practice, users should always read back any FITS files that they have created to ensure that the header values and data structure are correct and self-consistent.