Cannot load csr

When trying to load csr in pem format I get the error as write/read of a file failed. I am trying to load by directly calling the function x509_csr_parse_file() and not passing csr filename as command line argument.