Using files and handling errors