What are the potential pitfalls of using file_get_contents() to read a flatfile database in PHP?

Potential pitfalls of using file_get_contents() to read a flatfile database in PHP include limited error handling, lack of scalability for large databases, and potential security vulnerabilities if input is not properly sanitized.

// Use fopen() and fread() instead of file_get_contents() for better error handling and scalability

$filename = 'database.txt';
$handle = fopen($filename, 'r');

if ($handle) {
    $contents = fread($handle, filesize($filename));
    fclose($handle);

    // Process the contents of the file here
} else {
    echo 'Error opening file.';
}