Please help, not sure what's wrong
package com.codegym.task.task18.task1828;
/*
Prices 2
*/
import java.io.*;
import java.util.LinkedHashMap;
import java.util.Map;
public class Solution {
public static void main(String[] args) throws Exception {
if (args.length == 0) {
return;
}
LinkedHashMap<String, String> map = new LinkedHashMap<>();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String fileName = reader.readLine();
reader.close();
BufferedReader reader2 = new BufferedReader(new FileReader(fileName));
while (true) {
String line= reader2.readLine();
if (line == null) {
break;
}
else {
map.put(line.substring(0, 8), line.substring(9));
}
}
reader2.close();
if (args[0].equals("-u")) {
String id = args[1];
String productName = args[2];
String price = args[3];
String quantity = args[4];
while (id.length()<8) {
id += " ";
}
while (productName.length()<30) {
productName += " ";
}
while (price.length()<8) {
price += " ";
}
while (quantity.length()<4) {
quantity += " ";
}
for (Map.Entry<String, String> pair : map.entrySet()) {
String key = pair.getKey().trim();
if (key.equals(args[1])) {
pair.setValue(productName + price + quantity);
}
}
FileOutputStream output = new FileOutputStream(fileName);
for (Map.Entry<String, String> pair1 : map.entrySet()) {
output.write((pair1.getKey() + pair1.getValue()).getBytes());
}
output.close();
} else if (args[0].equals("-d")) {
map.remove(args[1]);
FileOutputStream output = new FileOutputStream(fileName);
for (Map.Entry<String, String> pair1 : map.entrySet()) {
output.write((pair1.getKey() + pair1.getValue()).getBytes());
}
output.close();
}
}
}