Managed the error checking and the sample file