diff --git a/frontends/sdl/src/main.rs b/frontends/sdl/src/main.rs
index d889266e797b4995218cf0fd55da67177bb94cca..46423c19837b236c6a4d88f9056ca3b3bf95ae4e 100644
--- a/frontends/sdl/src/main.rs
+++ b/frontends/sdl/src/main.rs
@@ -395,7 +395,7 @@ impl Emulator {
             // into a *.sav file in the file system
             if counter % store_count == 0 && self.system.rom().has_battery() {
                 let ram_data = self.system.rom().ram_data();
-                write_file(&self.ram_path, ram_data);
+                write_file(&self.ram_path, ram_data).unwrap();
             }
 
             // obtains an event from the SDL sub-system to be
diff --git a/src/gb.rs b/src/gb.rs
index 3d5047f3cc889c6e369cbe1d800f24298a4d7acd..8ee0bc18508b2dfefdbb95f7a9bebc9983401dd9 100644
--- a/src/gb.rs
+++ b/src/gb.rs
@@ -990,7 +990,7 @@ impl GameBoy {
     }
 
     pub fn load_boot_path(&mut self, path: &str) {
-        let data = read_file(path);
+        let data = read_file(path).unwrap();
         self.load_boot(&data);
     }
 
@@ -1031,10 +1031,10 @@ impl GameBoy {
     }
 
     pub fn load_rom_file(&mut self, path: &str, ram_path: Option<&str>) -> &mut Cartridge {
-        let data = read_file(path);
+        let data = read_file(path).unwrap();
         match ram_path {
             Some(ram_path) => {
-                let ram_data = read_file(ram_path);
+                let ram_data = read_file(ram_path).unwrap();
                 self.load_rom(&data, Some(&ram_data))
             }
             None => self.load_rom(&data, None),
diff --git a/src/rom.rs b/src/rom.rs
index a27ab71f2dfa0ab49110a742332e3ecbd45b8eaf..fd2418479f07f1aed467c409cc4e57ca13e0fc04 100644
--- a/src/rom.rs
+++ b/src/rom.rs
@@ -335,7 +335,7 @@ impl Cartridge {
     }
 
     pub fn from_file(path: &str) -> Self {
-        let data = read_file(path);
+        let data = read_file(path).unwrap();
         Self::from_data(&data)
     }
 
diff --git a/src/util.rs b/src/util.rs
index ae0ff7b34e6e3cbd3c00b0a5aa8dd24507147681..c2397337b157a78a2cabacb0b731965bbbaf7a7e 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -10,23 +10,24 @@ pub type SharedMut<T> = Rc<RefCell<T>>;
 
 /// Reads the contents of the file at the given path into
 /// a vector of bytes.
-pub fn read_file(path: &str) -> Vec<u8> {
+pub fn read_file(path: &str) -> Result<Vec<u8>, String> {
     let mut file = match File::open(path) {
         Ok(file) => file,
-        Err(_) => panic!("Failed to open file: {}", path),
+        Err(_) => return Err(format!("Failed to open file: {}", path)),
     };
     let mut data = Vec::new();
     file.read_to_end(&mut data).unwrap();
-    data
+    Ok(data)
 }
 
 /// Writes the given data to the file at the given path.
-pub fn write_file(path: &str, data: &[u8]) {
+pub fn write_file(path: &str, data: &[u8]) -> Result<(), String> {
     let mut file = match File::create(path) {
         Ok(file) => file,
-        Err(_) => panic!("Failed to open file: {}", path),
+        Err(_) => return Err(format!("Failed to open file: {}", path)),
     };
-    file.write_all(data).unwrap()
+    file.write_all(data).unwrap();
+    Ok(())
 }
 
 /// Replaces the extension in the given path with the provided extension.